Browse Source

p2p/addrbook: fix addToOldBucket

pull/859/head
Ethan Buchman 7 years ago
parent
commit
40e93a5f9e
2 changed files with 4 additions and 2 deletions
  1. +1
    -1
      p2p/addrbook.go
  2. +3
    -1
      p2p/addrbook_test.go

+ 1
- 1
p2p/addrbook.go View File

@ -475,7 +475,7 @@ func (a *AddrBook) addToOldBucket(ka *knownAddress, bucketIdx int) bool {
} }
addrStr := ka.Addr.String() addrStr := ka.Addr.String()
bucket := a.getBucket(bucketTypeNew, bucketIdx)
bucket := a.getBucket(bucketTypeOld, bucketIdx)
// Already exists? // Already exists?
if _, ok := bucket[addrStr]; ok { if _, ok := bucket[addrStr]; ok {


+ 3
- 1
p2p/addrbook_test.go View File

@ -53,8 +53,10 @@ func TestAddrBookPickAddress(t *testing.T) {
assert.NotNil(addr, "expected an address") assert.NotNil(addr, "expected an address")
addr = book.PickAddress(50) addr = book.PickAddress(50)
assert.NotNil(addr, "expected an address") assert.NotNil(addr, "expected an address")
// in this case, nNew==0 but we biased 100% to new, so we return nil
addr = book.PickAddress(100) addr = book.PickAddress(100)
assert.NotNil(addr, "expected an address")
assert.Nil(addr, "did not expected an address")
} }
func TestAddrBookSaveLoad(t *testing.T) { func TestAddrBookSaveLoad(t *testing.T) {


Loading…
Cancel
Save