mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
gossipd: don't broadcast node_announcement if we have no public channels.
This could always happen if we armed the timer when we did have public channels, and by the time we did our node_announcement we no longer did, but it gets triggered in our tests when we remove (our own!) zombied node_announcement in the next patch.
This commit is contained in:
parent
9e93826eea
commit
167209d595
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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(); }
|
||||
|
@ -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(); }
|
||||
|
Loading…
Reference in New Issue
Block a user