From 4aca909acbba18ad8531b4465fca3e0a24c0695c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 11 Apr 2018 08:33:12 +0930 Subject: [PATCH] routing: don't store node_announce unannounced nodes. We enter nodes in the map when we create channels, but those channels could be local and unannounced. This triggered a failure in test_gossip_persistence since the store truncated when it saw the first thing was a node_announce. Signed-off-by: Rusty Russell --- gossipd/routing.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gossipd/routing.c b/gossipd/routing.c index 0517d64b2..a68da88a1 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -1099,6 +1099,14 @@ bool routing_add_node_announcement(struct routing_state *rstate, const u8 *msg T return true; } +static bool node_has_public_channels(struct node *node) +{ + for (size_t i = 0; i < tal_count(node->chans); i++) + if (node->chans[i]->public) + return true; + return false; +} + u8 *handle_node_announcement(struct routing_state *rstate, const u8 *node_ann) { u8 *serialized; @@ -1187,6 +1195,8 @@ u8 *handle_node_announcement(struct routing_state *rstate, const u8 *node_ann) /* Beyond this point it's not malformed, so safe if we make it * pending and requeue later. */ node = get_node(rstate, &node_id); + if (node && !node_has_public_channels(node)) + node = NULL; /* Check if we are currently verifying the txout for a * matching channel */