Browse Source

fix broken merge

pull/1282/head
Anton Kaliaev 7 years ago
parent
commit
31deaa4a79
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 7 additions and 10 deletions
  1. +1
    -4
      p2p/pex/pex_reactor.go
  2. +6
    -6
      p2p/pex/pex_reactor_test.go

+ 1
- 4
p2p/pex/pex_reactor.go View File

@ -257,10 +257,7 @@ func (r *PEXReactor) ReceiveAddrs(addrs []*p2p.NetAddress, src Peer) error {
srcAddr := src.NodeInfo().NetAddress()
for _, netAddr := range addrs {
if netAddr == nil {
continue
}
if !isAddrPrivate(netAddr, r.config.PrivatePeerIDs) {
if netAddr != nil && !isAddrPrivate(netAddr, r.config.PrivatePeerIDs) {
r.book.AddAddress(netAddr, srcAddr)
}
}


+ 6
- 6
p2p/pex/pex_reactor_test.go View File

@ -269,21 +269,21 @@ func TestPEXReactorCrawlStatus(t *testing.T) {
}
func TestPEXReactorDoesNotAddPrivatePeersToAddrBook(t *testing.T) {
peer := p2p.CreateRandomPeer(false)
pexR, book := createReactor(&PEXReactorConfig{PrivatePeerIDs: []string{string(peer.NodeInfo().ID())}})
defer teardownReactor(book)
peer := p2p.CreateRandomPeer(false)
// we have to send a request to receive responses
r.RequestAddrs(peer)
pexR.RequestAddrs(peer)
size := book.Size()
addrs := []*p2p.NetAddress{peer.NodeInfo().NetAddress()}
msg := wire.BinaryBytes(struct{ PexMessage }{&pexAddrsMessage{Addrs: addrs}})
r.Receive(PexChannel, peer, msg)
pexR.Receive(PexChannel, peer, msg)
assert.Equal(t, size, book.Size())
r.AddPeer(peer)
pexR.AddPeer(peer)
assert.Equal(t, size, book.Size())
}
@ -395,7 +395,7 @@ func createReactor(config *PEXReactorConfig) (r *PEXReactor, book *addrBook) {
book = NewAddrBook(filepath.Join(dir, "addrbook.json"), true)
book.SetLogger(log.TestingLogger())
r = NewPEXReactor(book, &PEXReactorConfig{})
r = NewPEXReactor(book, config)
r.SetLogger(log.TestingLogger())
return
}


Loading…
Cancel
Save