diff --git a/gossipd/gossip_generation.c b/gossipd/gossip_generation.c index f95405c69..371446119 100644 --- a/gossipd/gossip_generation.c +++ b/gossipd/gossip_generation.c @@ -263,6 +263,10 @@ static bool update_own_node_announcement(struct daemon *daemon, /* Discard existing timer. */ daemon->node_announce_timer = tal_free(daemon->node_announce_timer); + /* If we don't have any channels now, don't send node_announcement */ + if (!self || !node_has_broadcastable_channels(self)) + goto reset_timer; + /* If we ever use set-based propagation, ensuring the toggle the lower * bit in consecutive timestamps makes it more robust. */ if (self && self->bcast.index @@ -327,6 +331,7 @@ static bool update_own_node_announcement(struct daemon *daemon, send: sign_and_send_nannounce(daemon, nannounce, timestamp); +reset_timer: /* Generate another one in 24 hours. */ setup_force_nannounce_regen_timer(daemon); @@ -341,13 +346,6 @@ static void update_own_node_announcement_after_startup(struct daemon *daemon) /* This creates and transmits a *new* node announcement */ static void force_self_nannounce_regen(struct daemon *daemon) { - struct node *self = get_node(daemon->rstate, &daemon->id); - /* Clear timer pointer now. */ - daemon->node_announce_regen_timer = NULL; - /* No channels left? We'll restart timer once we have one. */ - if (!self || !self->bcast.index) - return; - update_own_node_announcement(daemon, false, true); } diff --git a/gossipd/routing.c b/gossipd/routing.c index 3558684dd..b1608fa46 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -416,7 +416,7 @@ static bool is_node_zombie(struct node* node) /* 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) +bool node_has_broadcastable_channels(const struct node *node) { struct chan_map_iter i; struct chan *c; diff --git a/gossipd/routing.h b/gossipd/routing.h index b8aa671b7..f1666c167 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -434,6 +434,9 @@ bool would_ratelimit_cupdate(struct routing_state *rstate, const struct half_chan *hc, u32 timestamp); +/* Does this node have public, non-zombie channels? */ +bool node_has_broadcastable_channels(const struct node *node); + /* Returns an error string if there are unfinalized entries after load */ const char *unfinalized_entries(const tal_t *ctx, struct routing_state *rstate); diff --git a/gossipd/test/run-check_node_announcement.c b/gossipd/test/run-check_node_announcement.c index 6c0dabb28..0ccdd381f 100644 --- a/gossipd/test/run-check_node_announcement.c +++ b/gossipd/test/run-check_node_announcement.c @@ -68,6 +68,9 @@ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, struct timerel expire UNNEEDED, void (*cb)(void *) UNNEEDED, void *arg UNNEEDED) { fprintf(stderr, "new_reltimer_ called!\n"); abort(); } +/* Generated stub for node_has_broadcastable_channels */ +bool node_has_broadcastable_channels(const struct node *node UNNEEDED) +{ fprintf(stderr, "node_has_broadcastable_channels called!\n"); abort(); } /* Generated stub for queue_peer_msg */ void queue_peer_msg(struct peer *peer UNNEEDED, const u8 *msg TAKES UNNEEDED) { fprintf(stderr, "queue_peer_msg called!\n"); abort(); } diff --git a/gossipd/test/run-crc32_of_update.c b/gossipd/test/run-crc32_of_update.c index 3d61283e6..22b26c2d1 100644 --- a/gossipd/test/run-crc32_of_update.c +++ b/gossipd/test/run-crc32_of_update.c @@ -94,6 +94,9 @@ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, struct timerel expire UNNEEDED, void (*cb)(void *) UNNEEDED, void *arg UNNEEDED) { fprintf(stderr, "new_reltimer_ called!\n"); abort(); } +/* Generated stub for node_has_broadcastable_channels */ +bool node_has_broadcastable_channels(const struct node *node UNNEEDED) +{ fprintf(stderr, "node_has_broadcastable_channels called!\n"); abort(); } /* Generated stub for peer_supplied_good_gossip */ void peer_supplied_good_gossip(struct peer *peer UNNEEDED, size_t amount UNNEEDED) { fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); }