mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
gossipd: remove chainparams local var.
We have a global, let's use it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
170918ff8c
commit
5a95e9f29a
@ -305,7 +305,7 @@ static void update_local_channel(struct local_cupdate *lc /* frees! */)
|
||||
/* We create an update with a dummy signature, and hand to hsmd to get
|
||||
* it signed. */
|
||||
update = towire_channel_update_option_channel_htlc_max(tmpctx, &dummy_sig,
|
||||
&daemon->chain_hash,
|
||||
&chainparams->genesis_blockhash,
|
||||
&chan->scid,
|
||||
timestamp,
|
||||
message_flags, channel_flags,
|
||||
|
@ -841,9 +841,7 @@ static struct io_plan *gossip_init(struct io_conn *conn,
|
||||
master_badmsg(WIRE_GOSSIPCTL_INIT, msg);
|
||||
}
|
||||
|
||||
daemon->chain_hash = chainparams->genesis_blockhash;
|
||||
daemon->rstate = new_routing_state(daemon,
|
||||
chainparams_by_chainhash(&daemon->chain_hash),
|
||||
&daemon->id,
|
||||
&daemon->peers,
|
||||
&daemon->timers,
|
||||
|
@ -39,9 +39,6 @@ struct daemon {
|
||||
/* Routing information */
|
||||
struct routing_state *rstate;
|
||||
|
||||
/* chainhash for checking/making gossip msgs */
|
||||
struct bitcoin_blkid chain_hash;
|
||||
|
||||
/* Timers: we batch gossip, and also refresh announcements */
|
||||
struct timers timers;
|
||||
|
||||
|
@ -223,7 +223,8 @@ bool query_short_channel_ids(struct daemon *daemon,
|
||||
} else
|
||||
tlvs = NULL;
|
||||
|
||||
msg = towire_query_short_channel_ids(NULL, &daemon->chain_hash,
|
||||
msg = towire_query_short_channel_ids(NULL,
|
||||
&chainparams->genesis_blockhash,
|
||||
encoded, tlvs);
|
||||
queue_peer_msg(peer, take(msg));
|
||||
peer->scid_query_outstanding = true;
|
||||
@ -278,7 +279,7 @@ const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg)
|
||||
* - if does not maintain up-to-date channel information for `chain_hash`:
|
||||
* - MUST set `complete` to 0.
|
||||
*/
|
||||
if (!bitcoin_blkid_eq(&peer->daemon->chain_hash, &chain)) {
|
||||
if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain)) {
|
||||
status_peer_debug(&peer->id,
|
||||
"sent query_short_channel_ids chainhash %s",
|
||||
type_to_string(tmpctx, struct bitcoin_blkid, &chain));
|
||||
@ -370,7 +371,7 @@ static void reply_channel_range(struct peer *peer,
|
||||
tlvs->checksums_tlv = checksums;
|
||||
|
||||
u8 *msg = towire_reply_channel_range(NULL,
|
||||
&peer->daemon->chain_hash,
|
||||
&chainparams->genesis_blockhash,
|
||||
first_blocknum,
|
||||
number_of_blocks,
|
||||
1, encoded_scids, tlvs);
|
||||
@ -595,7 +596,7 @@ const u8 *handle_query_channel_range(struct peer *peer, const u8 *msg)
|
||||
* - if does not maintain up-to-date channel information for `chain_hash`:
|
||||
* - MUST set `complete` to 0.
|
||||
*/
|
||||
if (!bitcoin_blkid_eq(&peer->daemon->chain_hash, &chain_hash)) {
|
||||
if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain_hash)) {
|
||||
status_peer_debug(&peer->id,
|
||||
"query_channel_range with chainhash %s",
|
||||
type_to_string(tmpctx, struct bitcoin_blkid,
|
||||
@ -660,7 +661,7 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
|
||||
tal_hex(tmpctx, msg));
|
||||
}
|
||||
|
||||
if (!bitcoin_blkid_eq(&peer->daemon->chain_hash, &chain)) {
|
||||
if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain)) {
|
||||
return towire_errorfmt(peer, NULL,
|
||||
"reply_channel_range for bad chain: %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
@ -810,7 +811,7 @@ const u8 *handle_reply_short_channel_ids_end(struct peer *peer, const u8 *msg)
|
||||
tal_hex(tmpctx, msg));
|
||||
}
|
||||
|
||||
if (!bitcoin_blkid_eq(&peer->daemon->chain_hash, &chain)) {
|
||||
if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain)) {
|
||||
return towire_errorfmt(peer, NULL,
|
||||
"reply_short_channel_ids_end for bad chain: %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
@ -995,7 +996,7 @@ void maybe_send_query_responses(struct peer *peer)
|
||||
*/
|
||||
/* FIXME: We consider ourselves to have complete knowledge. */
|
||||
u8 *end = towire_reply_short_channel_ids_end(peer,
|
||||
&peer->daemon->chain_hash,
|
||||
&chainparams->genesis_blockhash,
|
||||
true);
|
||||
queue_peer_msg(peer, take(end));
|
||||
|
||||
@ -1044,7 +1045,7 @@ bool query_channel_range(struct daemon *daemon,
|
||||
"sending query_channel_range for blocks %u+%u",
|
||||
first_blocknum, number_of_blocks);
|
||||
|
||||
msg = towire_query_channel_range(NULL, &daemon->chain_hash,
|
||||
msg = towire_query_channel_range(NULL, &chainparams->genesis_blockhash,
|
||||
first_blocknum, number_of_blocks,
|
||||
tlvs);
|
||||
queue_peer_msg(peer, take(msg));
|
||||
|
@ -283,7 +283,6 @@ static bool in_txout_failures(struct routing_state *rstate,
|
||||
}
|
||||
|
||||
struct routing_state *new_routing_state(const tal_t *ctx,
|
||||
const struct chainparams *chainparams,
|
||||
const struct node_id *local_id,
|
||||
struct list_head *peers,
|
||||
struct timers *timers,
|
||||
@ -295,7 +294,6 @@ struct routing_state *new_routing_state(const tal_t *ctx,
|
||||
rstate->nodes = new_node_map(rstate);
|
||||
rstate->gs = gossip_store_new(rstate, peers);
|
||||
rstate->timers = timers;
|
||||
rstate->chainparams = chainparams;
|
||||
rstate->local_id = *local_id;
|
||||
rstate->local_channel_announced = false;
|
||||
rstate->last_timestamp = 0;
|
||||
@ -1770,8 +1768,7 @@ u8 *handle_channel_announcement(struct routing_state *rstate,
|
||||
* - if the specified `chain_hash` is unknown to the receiver:
|
||||
* - MUST ignore the message.
|
||||
*/
|
||||
if (!bitcoin_blkid_eq(&chain_hash,
|
||||
&rstate->chainparams->genesis_blockhash)) {
|
||||
if (!bitcoin_blkid_eq(&chain_hash, &chainparams->genesis_blockhash)) {
|
||||
status_peer_debug(peer ? &peer->id : NULL,
|
||||
"Received channel_announcement %s for unknown chain %s",
|
||||
type_to_string(pending, struct short_channel_id,
|
||||
@ -2146,8 +2143,8 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||
/* FIXME: https://github.com/lightningnetwork/lightning-rfc/pull/512
|
||||
* says we MUST NOT exceed 2^32-1, but c-lightning did, so just trim
|
||||
* rather than rejecting. */
|
||||
if (amount_msat_greater(htlc_maximum, rstate->chainparams->max_payment))
|
||||
htlc_maximum = rstate->chainparams->max_payment;
|
||||
if (amount_msat_greater(htlc_maximum, chainparams->max_payment))
|
||||
htlc_maximum = chainparams->max_payment;
|
||||
|
||||
set_connection_values(chan, direction, fee_base_msat,
|
||||
fee_proportional_millionths, expiry,
|
||||
@ -2301,8 +2298,7 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update TAKES,
|
||||
* active on the specified chain):
|
||||
* - MUST ignore the channel update.
|
||||
*/
|
||||
if (!bitcoin_blkid_eq(&chain_hash,
|
||||
&rstate->chainparams->genesis_blockhash)) {
|
||||
if (!bitcoin_blkid_eq(&chain_hash, &chainparams->genesis_blockhash)) {
|
||||
status_peer_debug(peer ? &peer->id : NULL,
|
||||
"Received channel_update for unknown chain %s",
|
||||
type_to_string(tmpctx, struct bitcoin_blkid,
|
||||
|
@ -260,9 +260,6 @@ static inline int half_chan_to(const struct node *n, const struct chan *chan)
|
||||
}
|
||||
|
||||
struct routing_state {
|
||||
/* Which chain we're on */
|
||||
const struct chainparams *chainparams;
|
||||
|
||||
/* TImers base from struct gossipd. */
|
||||
struct timers *timers;
|
||||
|
||||
@ -345,7 +342,6 @@ struct exclude_entry {
|
||||
};
|
||||
|
||||
struct routing_state *new_routing_state(const tal_t *ctx,
|
||||
const struct chainparams *chainparams,
|
||||
const struct node_id *local_id,
|
||||
struct list_head *peers,
|
||||
struct timers *timers,
|
||||
|
@ -204,7 +204,7 @@ static void disable_gossip_stream(struct seeker *seeker, struct peer *peer)
|
||||
|
||||
/* This is allowed even if they don't understand it (odd) */
|
||||
msg = towire_gossip_timestamp_filter(NULL,
|
||||
&seeker->daemon->chain_hash,
|
||||
&chainparams->genesis_blockhash,
|
||||
UINT32_MAX,
|
||||
UINT32_MAX);
|
||||
queue_peer_msg(peer, take(msg));
|
||||
@ -231,7 +231,7 @@ static void enable_gossip_stream(struct seeker *seeker, struct peer *peer)
|
||||
|
||||
/* This is allowed even if they don't understand it (odd) */
|
||||
msg = towire_gossip_timestamp_filter(NULL,
|
||||
&seeker->daemon->chain_hash,
|
||||
&chainparams->genesis_blockhash,
|
||||
start,
|
||||
UINT32_MAX);
|
||||
queue_peer_msg(peer, take(msg));
|
||||
|
@ -208,7 +208,7 @@ int main(int argc, char *argv[])
|
||||
setup_tmpctx();
|
||||
|
||||
me = nodeid(0);
|
||||
rstate = new_routing_state(tmpctx, NULL, &me, NULL, NULL, NULL,
|
||||
rstate = new_routing_state(tmpctx, &me, NULL, NULL, NULL,
|
||||
false, false);
|
||||
opt_register_noarg("--perfme", opt_set_bool, &perfme,
|
||||
"Run perfme-start and perfme-stop around benchmark");
|
||||
|
@ -161,7 +161,7 @@ int main(void)
|
||||
strlen("02cca6c5c966fcf61d121e3a70e03a1cd9eeeea024b26ea666ce974d43b242e636"),
|
||||
&d);
|
||||
|
||||
rstate = new_routing_state(tmpctx, NULL, &a, NULL, NULL, NULL, false, false);
|
||||
rstate = new_routing_state(tmpctx, &a, NULL, NULL, NULL, false, false);
|
||||
|
||||
/* [{'active': True, 'short_id': '6990:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'last_update': 1504064344}, */
|
||||
|
||||
|
@ -198,7 +198,7 @@ int main(void)
|
||||
|
||||
memset(&tmp, 'a', sizeof(tmp));
|
||||
node_id_from_privkey(&tmp, &a);
|
||||
rstate = new_routing_state(tmpctx, NULL, &a, NULL, NULL, NULL, false, false);
|
||||
rstate = new_routing_state(tmpctx, &a, NULL, NULL, NULL, false, false);
|
||||
|
||||
new_node(rstate, &a);
|
||||
|
||||
|
@ -122,7 +122,7 @@ int main(void)
|
||||
node_id_from_privkey(&tmp, &ids[i]);
|
||||
}
|
||||
/* We are node 0 */
|
||||
rstate = new_routing_state(tmpctx, NULL, &ids[0], NULL, NULL, NULL,
|
||||
rstate = new_routing_state(tmpctx, &ids[0], NULL, NULL, NULL,
|
||||
false, false);
|
||||
|
||||
for (size_t i = 0; i < NUM_NODES; i++) {
|
||||
|
@ -98,7 +98,7 @@ int main(void)
|
||||
|
||||
timers_init(&timers, time_mono());
|
||||
/* Random uninitalized node_id, we don't reference it. */
|
||||
rstate = new_routing_state(tmpctx, NULL, tal(tmpctx, struct node_id),
|
||||
rstate = new_routing_state(tmpctx, tal(tmpctx, struct node_id),
|
||||
NULL, &timers, NULL, false, false);
|
||||
|
||||
scid1.u64 = 100;
|
||||
|
Loading…
Reference in New Issue
Block a user