mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-31 19:36:20 +00:00
add peer to addrbook on AddPeer, after handshake
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user