Browse Source

fix off by one.

pull/9/head
Jae Kwon 11 years ago
parent
commit
c9114a677c
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      p2p/addrbook.go

+ 2
- 2
p2p/addrbook.go View File

@ -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")
}


Loading…
Cancel
Save