From 5ec454c7b2f9d5b90400c3eba7dcfcbec80f82f9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 4 Jun 2018 13:58:02 +0930 Subject: [PATCH] gossipd: don't queue node_announce unless we've queued channel_announce. We *accept* a node_announce if we have a channel_announce, but we can't queue it until we queue the channel_announce, which we only do once we have recieved a channel_update. Signed-off-by: Rusty Russell --- gossipd/routing.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gossipd/routing.c b/gossipd/routing.c index 83b53cf5a..03ddd362b 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -1180,6 +1180,7 @@ static struct wireaddr *read_addresses(const tal_t *ctx, const u8 *ser) return wireaddrs; } +/* We've received a channel_announce for a channel attached to this node */ static bool node_has_public_channels(struct node *node) { for (size_t i = 0; i < tal_count(node->chans); i++) @@ -1188,6 +1189,20 @@ static bool node_has_public_channels(struct node *node) return false; } +/* We can *send* a channel_announce for a channel attached to this node: + * we only send once we have a channel_update. */ +static bool node_has_broadcastable_channels(struct node *node) +{ + for (size_t i = 0; i < tal_count(node->chans); i++) { + if (!is_chan_public(node->chans[i])) + continue; + if (is_halfchan_defined(&node->chans[i]->half[0]) + || is_halfchan_defined(&node->chans[i]->half[1])) + return true; + } + return false; +} + bool routing_add_node_announcement(struct routing_state *rstate, const u8 *msg TAKES) { struct node *node; @@ -1229,7 +1244,7 @@ bool routing_add_node_announcement(struct routing_state *rstate, const u8 *msg T * order. It's not vital, but would be nice to fix. */ /* We might be waiting for channel_announce to be released. */ - node->node_announcement_public = node_has_public_channels(node); + node->node_announcement_public = node_has_broadcastable_channels(node); if (node->node_announcement_public) insert_broadcast(rstate->broadcasts, node->node_announcement, timestamp);