mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-04 07:07:13 +00:00
fix off by one.
This commit is contained in:
+2
-2
@@ -186,10 +186,10 @@ func (a *AddrBook) PickAddress(newBias int) *NetAddress {
|
||||
// pick a random ka from bucket.
|
||||
randIndex := a.rand.Intn(len(bucket))
|
||||
for _, ka := range bucket {
|
||||
randIndex--
|
||||
if randIndex == 0 {
|
||||
return ka.Addr
|
||||
}
|
||||
randIndex--
|
||||
}
|
||||
panic("Should not happen")
|
||||
} else {
|
||||
@@ -201,10 +201,10 @@ func (a *AddrBook) PickAddress(newBias int) *NetAddress {
|
||||
// pick a random ka from bucket.
|
||||
randIndex := a.rand.Intn(len(bucket))
|
||||
for _, ka := range bucket {
|
||||
randIndex--
|
||||
if randIndex == 0 {
|
||||
return ka.Addr
|
||||
}
|
||||
randIndex--
|
||||
}
|
||||
panic("Should not happen")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user