diff --git a/p2p/pex_reactor.go b/p2p/pex_reactor.go index d32888ff8..5376e2527 100644 --- a/p2p/pex_reactor.go +++ b/p2p/pex_reactor.go @@ -76,8 +76,11 @@ func (pexR *PEXReactor) GetChannels() []*ChannelDescriptor { // Implements Reactor func (pexR *PEXReactor) AddPeer(peer *Peer) { + // Add the peer to the address book + netAddr := NewNetAddressString(fmt.Sprintf("%s:%d", peer.Host, peer.P2PPort)) + pexR.book.AddAddress(netAddr, netAddr) // the peer is its own source + if peer.IsOutbound() { - pexR.SendAddrs(peer, pexR.book.OurAddresses()) if pexR.book.NeedMoreAddrs() { pexR.RequestPEX(peer) } diff --git a/p2p/switch.go b/p2p/switch.go index 2702f5930..a7c683089 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -202,8 +202,8 @@ func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) (*Peer, er } func (sw *Switch) startInitPeer(peer *Peer) { - peer.start() - sw.addPeerToReactors(peer) + peer.start() // spawn send/recv routines + sw.addPeerToReactors(peer) // run AddPeer on each reactor } func (sw *Switch) DialPeerWithAddress(addr *NetAddress) (*Peer, error) { @@ -306,7 +306,7 @@ func (sw *Switch) listenerRoutine(l Listener) { } // NOTE: We don't yet have the external address of the // remote (if they have a listener at all). - // PEXReactor's pexRoutine will handle that. + // The peerHandshake will take care of that } // cleanup