From e765a2772daf5a1a970664629369fcf6d99e2157 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 5 Nov 2019 22:23:33 +0000 Subject: [PATCH] fix(bootstrap): don't bootstrap more than 16 buckets We can't generate target IDs in buckets beyond bucket 15 so there's no point. --- dht_bootstrap.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dht_bootstrap.go b/dht_bootstrap.go index cf1a765a9..dd82c25ae 100644 --- a/dht_bootstrap.go +++ b/dht_bootstrap.go @@ -95,6 +95,12 @@ func (dht *IpfsDHT) bootstrapBuckets(ctx context.Context) { } buckets := dht.routingTable.GetAllBuckets() + if len(buckets) > 16 { + // Don't bother bootstrapping more than 16 buckets. + // GenRandPeerID can't generate target peer IDs with more than + // 16 bits specified anyways. + buckets = buckets[:16] + } for bucketID, bucket := range buckets { if time.Since(bucket.RefreshedAt()) > dht.bootstrapPeriod { // gen rand peer in the bucket