Skip to content

Commit 97c7ba2

Browse files
rustyrussellcdecker
authored andcommitted
gossipd: fix reordering of node_announcements in presence of a unannounced channel.
If we receive a channel_announce but not a channel_update, we store the announce but don't put it in the broadcast map. When we delete a channel, we check if the node_announcement broadcast now preceeds all channel_announcements, and if so, we move it to the end of the map. However, with a channel_announcement at index '0', this test fails. This is at least one potential cause of the node map getting out of order. Signed-off-by: Rusty Russell <[email protected]>
1 parent e2f4269 commit 97c7ba2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

gossipd/routing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static bool remove_channel_from_array(struct chan ***chans, const struct chan *c
199199
static bool node_announce_predates_channels(const struct node *node)
200200
{
201201
for (size_t i = 0; i < tal_count(node->chans); i++) {
202-
if (!is_chan_public(node->chans[i]))
202+
if (!is_chan_announced(node->chans[i]))
203203
continue;
204204

205205
if (node->chans[i]->channel_announcement_index

gossipd/routing.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,19 @@ struct chan {
6161
u64 satoshis;
6262
};
6363

64+
/* A local channel can exist which isn't announcable. */
6465
static inline bool is_chan_public(const struct chan *chan)
6566
{
6667
return chan->channel_announce != NULL;
6768
}
6869

70+
/* A channel is only announced once we have a channel_update to send
71+
* with it. */
72+
static inline bool is_chan_announced(const struct chan *chan)
73+
{
74+
return chan->channel_announcement_index != 0;
75+
}
76+
6977
static inline bool is_halfchan_defined(const struct half_chan *hc)
7078
{
7179
return hc->channel_update != NULL;

0 commit comments

Comments
 (0)