diff --git a/p2p/addrbook.go b/p2p/addrbook.go index 6de81924b..5a3a60c2b 100644 --- a/p2p/addrbook.go +++ b/p2p/addrbook.go @@ -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") }