Skip to content

Commit

Permalink
fix(bootstrap): don't bootstrap more than 16 buckets
Browse files Browse the repository at this point in the history
We can't generate target IDs in buckets beyond bucket 15 so there's no point.
  • Loading branch information
Stebalien committed Nov 5, 2019
1 parent d1ff842 commit e765a27
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dht_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e765a27

Please sign in to comment.