mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 00:54:20 +01:00
gossipd: force a fresh node_announcement every 24 hours.
Even if nothing has changed. Note that this is different from simply re-xmitting the old one, in that it has a different timestamp, so others will re-xmit it too. This is a side-effect of reports that node_announcement propagation through the network is poor: https://github.com/ElementsProject/lightning/issues/5037 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Protocol: We now refresh our ndoe_announcement every 24 hours, due to propagation issues.
This commit is contained in:
@@ -214,13 +214,16 @@ static void sign_and_send_nannounce(struct daemon *daemon,
|
|||||||
|
|
||||||
/* Mutual recursion via timer */
|
/* Mutual recursion via timer */
|
||||||
static void update_own_node_announcement_after_startup(struct daemon *daemon);
|
static void update_own_node_announcement_after_startup(struct daemon *daemon);
|
||||||
|
static void setup_force_nannounce_regen_timer(struct daemon *daemon);
|
||||||
|
|
||||||
/* This routine created a `node_announcement` for our node, and hands it to
|
/* This routine created a `node_announcement` for our node, and hands it to
|
||||||
* 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. */
|
||||||
/* Returns true if this sent one, or has arranged to send one in future. */
|
/* 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)
|
static bool update_own_node_announcement(struct daemon *daemon,
|
||||||
|
bool startup,
|
||||||
|
bool always_refresh)
|
||||||
{
|
{
|
||||||
u32 timestamp = gossip_time_now(daemon->rstate).ts.tv_sec;
|
u32 timestamp = gossip_time_now(daemon->rstate).ts.tv_sec;
|
||||||
u8 *nannounce;
|
u8 *nannounce;
|
||||||
@@ -247,6 +250,8 @@ static bool update_own_node_announcement(struct daemon *daemon, bool startup)
|
|||||||
|
|
||||||
if (!nannounce_different(daemon->rstate->gs, self, nannounce,
|
if (!nannounce_different(daemon->rstate->gs, self, nannounce,
|
||||||
&only_missing_tlv)) {
|
&only_missing_tlv)) {
|
||||||
|
if (always_refresh)
|
||||||
|
goto send;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +293,12 @@ static bool update_own_node_announcement(struct daemon *daemon, bool startup)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send:
|
||||||
sign_and_send_nannounce(daemon, nannounce, timestamp);
|
sign_and_send_nannounce(daemon, nannounce, timestamp);
|
||||||
|
|
||||||
|
/* Generate another one in 24 hours. */
|
||||||
|
setup_force_nannounce_regen_timer(daemon);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,10 +313,36 @@ static void force_self_nannounce_rexmit(struct daemon *daemon)
|
|||||||
static void update_own_node_announcement_after_startup(struct daemon *daemon)
|
static void update_own_node_announcement_after_startup(struct daemon *daemon)
|
||||||
{
|
{
|
||||||
/* If that doesn't send one, arrange rexmit anyway */
|
/* If that doesn't send one, arrange rexmit anyway */
|
||||||
if (!update_own_node_announcement(daemon, false))
|
if (!update_own_node_announcement(daemon, false, false))
|
||||||
force_self_nannounce_rexmit(daemon);
|
force_self_nannounce_rexmit(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);
|
||||||
|
|
||||||
|
/* No channels left? We'll restart timer once we have one. */
|
||||||
|
if (!self || !self->bcast.index)
|
||||||
|
return;
|
||||||
|
|
||||||
|
update_own_node_announcement(daemon, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Because node_announcement propagation is spotty, we rexmit this every
|
||||||
|
* 24 hours. */
|
||||||
|
static void setup_force_nannounce_regen_timer(struct daemon *daemon)
|
||||||
|
{
|
||||||
|
tal_free(daemon->node_announce_regen_timer);
|
||||||
|
daemon->node_announce_regen_timer
|
||||||
|
= new_reltimer(&daemon->timers,
|
||||||
|
daemon,
|
||||||
|
time_from_sec(24 * 3600),
|
||||||
|
force_self_nannounce_regen,
|
||||||
|
daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Should we announce our own node? Called at strategic places. */
|
/* Should we announce our own node? Called at strategic places. */
|
||||||
void maybe_send_own_node_announce(struct daemon *daemon, bool startup)
|
void maybe_send_own_node_announce(struct daemon *daemon, bool startup)
|
||||||
{
|
{
|
||||||
@@ -318,7 +354,7 @@ void maybe_send_own_node_announce(struct daemon *daemon, bool startup)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* If we didn't send one, arrange rexmit of existing at startup */
|
/* If we didn't send one, arrange rexmit of existing at startup */
|
||||||
if (!update_own_node_announcement(daemon, startup)) {
|
if (!update_own_node_announcement(daemon, startup, false)) {
|
||||||
if (startup)
|
if (startup)
|
||||||
force_self_nannounce_rexmit(daemon);
|
force_self_nannounce_rexmit(daemon);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1059,6 +1059,7 @@ int main(int argc, char *argv[])
|
|||||||
list_head_init(&daemon->peers);
|
list_head_init(&daemon->peers);
|
||||||
daemon->deferred_txouts = tal_arr(daemon, struct short_channel_id, 0);
|
daemon->deferred_txouts = tal_arr(daemon, struct short_channel_id, 0);
|
||||||
daemon->node_announce_timer = NULL;
|
daemon->node_announce_timer = NULL;
|
||||||
|
daemon->node_announce_regen_timer = NULL;
|
||||||
daemon->current_blockheight = 0; /* i.e. unknown */
|
daemon->current_blockheight = 0; /* i.e. unknown */
|
||||||
daemon->rates = NULL;
|
daemon->rates = NULL;
|
||||||
list_head_init(&daemon->deferred_updates);
|
list_head_init(&daemon->deferred_updates);
|
||||||
|
|||||||
@@ -47,9 +47,12 @@ struct daemon {
|
|||||||
/* What addresses we can actually announce. */
|
/* What addresses we can actually announce. */
|
||||||
struct wireaddr *announcable;
|
struct wireaddr *announcable;
|
||||||
|
|
||||||
/* Timer until we can send a new node_announcement */
|
/* Timer until we can send an updated node_announcement */
|
||||||
struct oneshot *node_announce_timer;
|
struct oneshot *node_announce_timer;
|
||||||
|
|
||||||
|
/* Timer until we should force a new new node_announcement */
|
||||||
|
struct oneshot *node_announce_regen_timer;
|
||||||
|
|
||||||
/* Channels we have an announce for, but aren't deep enough. */
|
/* Channels we have an announce for, but aren't deep enough. */
|
||||||
struct short_channel_id *deferred_txouts;
|
struct short_channel_id *deferred_txouts;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user