From b03b049c57d1d6e8a43ef89abaca29d15ee1625c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 31 Jan 2024 13:46:18 +1030 Subject: [PATCH] lightningd: don't create node_announcement until gossipd is finished. It might be redundant. Signed-off-by: Rusty Russell --- lightningd/channel_gossip.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lightningd/channel_gossip.c b/lightningd/channel_gossip.c index 32c4a9f5e..28b37ad12 100644 --- a/lightningd/channel_gossip.c +++ b/lightningd/channel_gossip.c @@ -53,7 +53,7 @@ struct channel_gossip { /* FIXME: this is a hack! We should wait 1 minute after connectd has * tried to connect to all peers. */ -static bool starting_up = true; +static bool starting_up = true, gossipd_init_done = false; /* We send non-forwardable channel updates if we can. */ static bool can_send_channel_update(const struct channel *channel) @@ -802,6 +802,7 @@ void channel_gossip_init_done(struct lightningd *ld) struct channel *channel; struct peer_node_id_map_iter it; + gossipd_init_done = true; for (peer = peer_node_id_map_first(ld->peers, &it); peer; peer = peer_node_id_map_next(ld->peers, &it)) { @@ -1030,6 +1031,11 @@ void channel_gossip_node_announce(struct lightningd *ld) if (!has_announced_channels(ld)) return; + /* Don't produce a node announcement until *after* gossipd has + * told us it's finished. */ + if (!gossipd_init_done) + return; + nannounce = unsigned_node_announcement(tmpctx, ld); /* Don't bother with duplicates */