Skip to content

Commit

Permalink
gossipd: hand gossmap to gossmap_manage_get_node_addresses, not gossm…
Browse files Browse the repository at this point in the history
…ap_manage.

We don't want to to refresh the gossmap internally: this could invalidate the
gossmap held by the current callers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Nov 22, 2024
1 parent 69c252e commit d5c0d21
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ static struct io_plan *handle_get_address(struct io_conn *conn,
{
struct node_id id;
struct wireaddr *addrs;
struct gossmap *gossmap = gossmap_manage_get_gossmap(daemon->gm);

if (!fromwire_gossipd_get_addrs(msg, &id))
master_badmsg(WIRE_GOSSIPD_GET_ADDRS, msg);

addrs = gossmap_manage_get_node_addresses(tmpctx,
daemon->gm,
gossmap,
&id);

daemon_conn_send(daemon->master,
Expand Down
3 changes: 1 addition & 2 deletions gossipd/gossmap_manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ void gossmap_manage_tell_lightningd_locals(struct daemon *daemon,
}

struct wireaddr *gossmap_manage_get_node_addresses(const tal_t *ctx,
struct gossmap_manage *gm,
struct gossmap *gossmap,
const struct node_id *node_id)
{
struct gossmap_node *node;
Expand All @@ -1447,7 +1447,6 @@ struct wireaddr *gossmap_manage_get_node_addresses(const tal_t *ctx,
u8 rgb_color[3], alias[32];
struct tlv_node_ann_tlvs *na_tlvs;
struct wireaddr *wireaddrs;
struct gossmap *gossmap = gossmap_manage_get_gossmap(gm);

node = gossmap_find_node(gossmap, node_id);
if (!node)
Expand Down
4 changes: 2 additions & 2 deletions gossipd/gossmap_manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ void gossmap_manage_new_peer(struct gossmap_manage *gm,
/**
* gossmap_manage_get_node_addresses: get addresses for this node.
* @ctx: the allocation context
* @gm: the gossmap_manage context
* @gossmap: the gossmap
* @node_id: the node_id to look up
*
* Returns NULL if we don't have node_announcement for it.
*/
struct wireaddr *gossmap_manage_get_node_addresses(const tal_t *ctx,
struct gossmap_manage *gm,
struct gossmap *gossmap,
const struct node_id *node_id);

/**
Expand Down
2 changes: 1 addition & 1 deletion gossipd/seeker.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ static struct node_and_addrs *get_random_node(const tal_t *ctx,
gossmap_node_get_id(gossmap, node, found_node->id);
found_node->addrs =
gossmap_manage_get_node_addresses(found_node,
seeker->daemon->gm,
gossmap,
found_node->id);
if (found_node->addrs && tal_count(found_node->addrs) != 0)
return found_node;
Expand Down
8 changes: 4 additions & 4 deletions gossipd/test/run-next_block_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct gossmap *gossmap_manage_get_gossmap(struct gossmap_manage *gm UNNEEDED)
{ fprintf(stderr, "gossmap_manage_get_gossmap called!\n"); abort(); }
/* Generated stub for gossmap_manage_get_node_addresses */
struct wireaddr *gossmap_manage_get_node_addresses(const tal_t *ctx UNNEEDED,
struct gossmap_manage *gm UNNEEDED,
struct gossmap *gossmap UNNEEDED,
const struct node_id *node_id UNNEEDED)
{ fprintf(stderr, "gossmap_manage_get_node_addresses called!\n"); abort(); }
/* Generated stub for gossmap_max_node_idx */
Expand All @@ -92,9 +92,9 @@ struct gossmap_node *gossmap_nth_node(const struct gossmap *map UNNEEDED,
const struct gossmap_chan *chan UNNEEDED,
int n UNNEEDED)
{ fprintf(stderr, "gossmap_nth_node called!\n"); abort(); }
/* Generated stub for gossmap_num_nodes */
size_t gossmap_num_nodes(const struct gossmap *map UNNEEDED)
{ fprintf(stderr, "gossmap_num_nodes called!\n"); abort(); }
/* Generated stub for gossmap_random_node */
struct gossmap_node *gossmap_random_node(const struct gossmap *map UNNEEDED)
{ fprintf(stderr, "gossmap_random_node called!\n"); abort(); }
/* Generated stub for memleak_scan_intmap_ */
void memleak_scan_intmap_(struct htable *memtable UNNEEDED, const struct intmap *m UNNEEDED)
{ fprintf(stderr, "memleak_scan_intmap_ called!\n"); abort(); }
Expand Down
2 changes: 1 addition & 1 deletion wallet/test/run-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx UNNEEDED,
{ fprintf(stderr, "new_coin_wallet_deposit called!\n"); abort(); }
/* Generated stub for new_inflight */
struct channel_inflight *new_inflight(struct channel *channel UNNEEDED,
struct pubkey *remote_funding UNNEEDED,
struct pubkey *remote_funding STEALS UNNEEDED,
const struct bitcoin_outpoint *funding_outpoint UNNEEDED,
u32 funding_feerate UNNEEDED,
struct amount_sat funding_sat UNNEEDED,
Expand Down

0 comments on commit d5c0d21

Please sign in to comment.