mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
gossipd: don't queue node_announce unless we've queued channel_announce.
We *accept* a node_announce if we have a channel_announce, but we can't queue it until we queue the channel_announce, which we only do once we have recieved a channel_update. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e9483f12b6
commit
5ec454c7b2
1 changed files with 16 additions and 1 deletions
|
@ -1180,6 +1180,7 @@ static struct wireaddr *read_addresses(const tal_t *ctx, const u8 *ser)
|
|||
return wireaddrs;
|
||||
}
|
||||
|
||||
/* We've received a channel_announce for a channel attached to this node */
|
||||
static bool node_has_public_channels(struct node *node)
|
||||
{
|
||||
for (size_t i = 0; i < tal_count(node->chans); i++)
|
||||
|
@ -1188,6 +1189,20 @@ static bool node_has_public_channels(struct node *node)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
for (size_t i = 0; i < tal_count(node->chans); i++) {
|
||||
if (!is_chan_public(node->chans[i]))
|
||||
continue;
|
||||
if (is_halfchan_defined(&node->chans[i]->half[0])
|
||||
|| is_halfchan_defined(&node->chans[i]->half[1]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool routing_add_node_announcement(struct routing_state *rstate, const u8 *msg TAKES)
|
||||
{
|
||||
struct node *node;
|
||||
|
@ -1229,7 +1244,7 @@ bool routing_add_node_announcement(struct routing_state *rstate, const u8 *msg T
|
|||
* order. It's not vital, but would be nice to fix.
|
||||
*/
|
||||
/* We might be waiting for channel_announce to be released. */
|
||||
node->node_announcement_public = node_has_public_channels(node);
|
||||
node->node_announcement_public = node_has_broadcastable_channels(node);
|
||||
if (node->node_announcement_public)
|
||||
insert_broadcast(rstate->broadcasts, node->node_announcement,
|
||||
timestamp);
|
||||
|
|
Loading…
Add table
Reference in a new issue