Skip to content

Commit 79df507

Browse files
rustyrussellniftynei
authored andcommitted
gossipd: exclude early blocks from random probes.
When probing, no point probing for before lightning became cool. Current logic means we often probe below block 500,000, and think things are OK because there are no short_channel_ids. Signed-off-by: Rusty Russell <[email protected]>
1 parent be49a59 commit 79df507

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

gossipd/seeker.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,13 +717,23 @@ static void peer_gossip_probe_scids(struct seeker *seeker)
717717

718718
static void probe_random_scids(struct seeker *seeker, size_t num_blocks)
719719
{
720-
if (seeker->daemon->current_blockheight < num_blocks) {
720+
u32 avail_blocks;
721+
722+
/* Ignore early blocks (unless we're before, which would be weird) */
723+
if (seeker->daemon->current_blockheight
724+
< chainparams->when_lightning_became_cool)
725+
avail_blocks = seeker->daemon->current_blockheight;
726+
else
727+
avail_blocks = seeker->daemon->current_blockheight
728+
- chainparams->when_lightning_became_cool;
729+
730+
if (avail_blocks < num_blocks) {
721731
seeker->scid_probe_start = 0;
722732
seeker->scid_probe_end = seeker->daemon->current_blockheight;
723733
} else {
724734
seeker->scid_probe_start
725-
= pseudorand(seeker->daemon->current_blockheight
726-
- num_blocks);
735+
= chainparams->when_lightning_became_cool
736+
+ pseudorand(avail_blocks - num_blocks);
727737
seeker->scid_probe_end
728738
= seeker->scid_probe_start + num_blocks - 1;
729739
}

0 commit comments

Comments
 (0)