From 79df507442df9f42fc80c0333f552860099b5528 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 18 Oct 2019 20:40:50 +1030 Subject: [PATCH] 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 --- gossipd/seeker.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gossipd/seeker.c b/gossipd/seeker.c index ba2ac2ed5..1d2af98da 100644 --- a/gossipd/seeker.c +++ b/gossipd/seeker.c @@ -717,13 +717,23 @@ static void peer_gossip_probe_scids(struct seeker *seeker) static void probe_random_scids(struct seeker *seeker, size_t num_blocks) { - if (seeker->daemon->current_blockheight < num_blocks) { + u32 avail_blocks; + + /* Ignore early blocks (unless we're before, which would be weird) */ + if (seeker->daemon->current_blockheight + < chainparams->when_lightning_became_cool) + avail_blocks = seeker->daemon->current_blockheight; + else + avail_blocks = seeker->daemon->current_blockheight + - chainparams->when_lightning_became_cool; + + if (avail_blocks < num_blocks) { seeker->scid_probe_start = 0; seeker->scid_probe_end = seeker->daemon->current_blockheight; } else { seeker->scid_probe_start - = pseudorand(seeker->daemon->current_blockheight - - num_blocks); + = chainparams->when_lightning_became_cool + + pseudorand(avail_blocks - num_blocks); seeker->scid_probe_end = seeker->scid_probe_start + num_blocks - 1; }