gossipd: always re-sent our own node_announcement on startup.

Even if it hasn't changed, re-send it to everyone.  That should help
propagation a little.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-03-03 14:30:22 +10:30
parent d991f13516
commit bf8cb640b7
3 changed files with 30 additions and 7 deletions

View File

@ -219,7 +219,8 @@ static void update_own_node_announcement_after_startup(struct daemon *daemon);
* the routing.c code like any other `node_announcement`. Such announcements * the routing.c code like any other `node_announcement`. Such announcements
* are only accepted if there is an announced channel associated with that node * are only accepted if there is an announced channel associated with that node
* (to prevent spam), so we only call this once we've announced a channel. */ * (to prevent spam), so we only call this once we've announced a channel. */
static void update_own_node_announcement(struct daemon *daemon, bool startup) /* Returns true if this sent one, or has arranged to send one in future. */
static bool update_own_node_announcement(struct daemon *daemon, bool startup)
{ {
u32 timestamp = gossip_time_now(daemon->rstate).ts.tv_sec; u32 timestamp = gossip_time_now(daemon->rstate).ts.tv_sec;
u8 *nannounce; u8 *nannounce;
@ -245,8 +246,9 @@ static void update_own_node_announcement(struct daemon *daemon, bool startup)
bool only_missing_tlv; bool only_missing_tlv;
if (!nannounce_different(daemon->rstate->gs, self, nannounce, if (!nannounce_different(daemon->rstate->gs, self, nannounce,
&only_missing_tlv)) &only_missing_tlv)) {
return; return false;
}
/* Missing liquidity_ad, maybe we'll get plugin callback */ /* Missing liquidity_ad, maybe we'll get plugin callback */
if (startup && only_missing_tlv) { if (startup && only_missing_tlv) {
@ -260,7 +262,7 @@ static void update_own_node_announcement(struct daemon *daemon, bool startup)
time_from_sec(delay), time_from_sec(delay),
update_own_node_announcement_after_startup, update_own_node_announcement_after_startup,
daemon); daemon);
return; return true;
} }
/* BOLT #7: /* BOLT #7:
* *
@ -282,16 +284,27 @@ static void update_own_node_announcement(struct daemon *daemon, bool startup)
time_from_sec(next - timestamp), time_from_sec(next - timestamp),
update_own_node_announcement_after_startup, update_own_node_announcement_after_startup,
daemon); daemon);
return; return true;
} }
} }
sign_and_send_nannounce(daemon, nannounce, timestamp); sign_and_send_nannounce(daemon, nannounce, timestamp);
return true;
}
/* This retransmits the existing node announcement */
static void force_self_nannounce_rexmit(struct daemon *daemon)
{
struct node *self = get_node(daemon->rstate, &daemon->id);
force_node_announce_rexmit(daemon->rstate, self);
} }
static void update_own_node_announcement_after_startup(struct daemon *daemon) static void update_own_node_announcement_after_startup(struct daemon *daemon)
{ {
update_own_node_announcement(daemon, false); /* If that doesn't send one, arrange rexmit anyway */
if (!update_own_node_announcement(daemon, false))
force_self_nannounce_rexmit(daemon);
} }
/* Should we announce our own node? Called at strategic places. */ /* Should we announce our own node? Called at strategic places. */
@ -304,7 +317,11 @@ void maybe_send_own_node_announce(struct daemon *daemon, bool startup)
if (!daemon->rstate->local_channel_announced) if (!daemon->rstate->local_channel_announced)
return; return;
update_own_node_announcement(daemon, startup); /* If we didn't send one, arrange rexmit of existing at startup */
if (!update_own_node_announcement(daemon, startup)) {
if (startup)
force_self_nannounce_rexmit(daemon);
}
} }
/* Fast accessors for channel_update fields */ /* Fast accessors for channel_update fields */

View File

@ -36,6 +36,9 @@ struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id
/* Generated stub for fmt_wireaddr_without_port */ /* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED) char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); } { fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for force_node_announce_rexmit */
void force_node_announce_rexmit(struct routing_state *rstate UNNEEDED, struct node *node UNNEEDED)
{ fprintf(stderr, "force_node_announce_rexmit called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_channel_update */ /* Generated stub for fromwire_gossipd_local_channel_update */
bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct node_id *id UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED) bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct node_id *id UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_channel_update called!\n"); abort(); } { fprintf(stderr, "fromwire_gossipd_local_channel_update called!\n"); abort(); }

View File

@ -54,6 +54,9 @@ struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id
/* Generated stub for fmt_wireaddr_without_port */ /* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED) char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); } { fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for force_node_announce_rexmit */
void force_node_announce_rexmit(struct routing_state *rstate UNNEEDED, struct node *node UNNEEDED)
{ fprintf(stderr, "force_node_announce_rexmit called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_dev_set_max_scids_encode_size */ /* Generated stub for fromwire_gossipd_dev_set_max_scids_encode_size */
bool fromwire_gossipd_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED) bool fromwire_gossipd_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_dev_set_max_scids_encode_size called!\n"); abort(); } { fprintf(stderr, "fromwire_gossipd_dev_set_max_scids_encode_size called!\n"); abort(); }