gossipd: make sure we set the `urgent` bit if we move our own node_announcement.

node_announcement has to follow at least one channel_announcement.
When channels close, if this isn't the case, we remove the old
node_announcement and put it at the end of the gossip_store.

But we lose the "send even if they don't want it" bit in the case it's
our own node_announceent, so keep it.

This only happens if you don't change your node configuration at all
since you opened your first channel, but still worth fixing.

We expose the force_node_announce_rexmit() for later use.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-03-03 14:29:28 +10:30
parent b5a1715c2b
commit d991f13516
2 changed files with 24 additions and 13 deletions

View File

@ -421,6 +421,25 @@ static bool node_announce_predates_channels(const struct node *node)
return true;
}
/* Move this node's announcement to the tail of the gossip_store, to
* make everyone send it again. */
void force_node_announce_rexmit(struct routing_state *rstate,
struct node *node)
{
const u8 *announce;
bool is_local = node_id_eq(&node->id, &rstate->local_id);
announce = gossip_store_get(tmpctx, rstate->gs, node->bcast.index);
gossip_store_delete(rstate->gs,
&node->bcast,
WIRE_NODE_ANNOUNCEMENT);
node->bcast.index = gossip_store_add(rstate->gs,
announce,
node->bcast.timestamp,
is_local,
NULL);
}
static void remove_chan_from_node(struct routing_state *rstate,
struct node *node, const struct chan *chan)
{
@ -458,23 +477,11 @@ static void remove_chan_from_node(struct routing_state *rstate,
&node->bcast,
WIRE_NODE_ANNOUNCEMENT);
} else if (node_announce_predates_channels(node)) {
const u8 *announce;
announce = gossip_store_get(tmpctx, rstate->gs,
node->bcast.index);
/* node announcement predates all channel announcements?
* Move to end (we could, in theory, move to just past next
* channel_announce, but we don't care that much about spurious
* retransmissions in this corner case */
gossip_store_delete(rstate->gs,
&node->bcast,
WIRE_NODE_ANNOUNCEMENT);
node->bcast.index = gossip_store_add(rstate->gs,
announce,
node->bcast.timestamp,
false,
NULL);
force_node_announce_rexmit(rstate, node);
}
}

View File

@ -406,4 +406,8 @@ void remove_all_gossip(struct routing_state *rstate);
/* This scid is dead to us. */
void add_to_txout_failures(struct routing_state *rstate,
const struct short_channel_id *scid);
/* Move this node's announcement to the tail of the gossip_store, to
* make everyone send it again. */
void force_node_announce_rexmit(struct routing_state *rstate, struct node *node);
#endif /* LIGHTNING_GOSSIPD_ROUTING_H */