Commit 33746c1a authored by Steven Allen's avatar Steven Allen

don't even try to target a bucket >= bucket 16

parent 7f507318
......@@ -77,12 +77,17 @@ func (rt *RoutingTable) GenRandPeerID(bucketID int) (peer.ID, error) {
rt.tabLock.RUnlock()
var targetCpl int
if bucketID >= bucketLen-1 {
if bucketID > (bucketLen - 1) {
targetCpl = bucketLen - 1
} else {
targetCpl = bucketID
}
// We can only handle 16 bit prefixes.
if targetCpl > 16 {
targetCpl = 16
}
// generate random 16 bits
r := rand.New(rand.NewSource(time.Now().UnixNano()))
buf := make([]byte, 2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment