pex_reactor.go
func (r *PEXReactor) AddPeer(p *Peer) {
	if p.IsOutbound() {
		// For outbound peers, the address is already in the books.
		// Either it was added in DialSeeds or when we
		// received the peer's address in r.Receive
		if r.book.NeedMoreAddrs() {
			r.RequestPEX(p)
		}
	} else { // For inbound connections, the peer is its own source
		addr, err := NewNetAddressString(p.ListenAddr)
		if err != nil {
			// this should never happen
			log.Error("Error in AddPeer: invalid peer address", "addr", p.ListenAddr, "error", err)
			return
		}
		r.book.AddAddress(addr, addr)
	}
}
func (r *PEXReactor) AddPeer(p *Peer) {
	if p.IsOutbound() {
		// For outbound peers, the address is already in the books.
		// Either it was added in DialSeeds or when we
		// received the peer's address in r.Receive
		if r.book.NeedMoreAddrs() {
			r.RequestPEX(p)
		}
	} else { // For inbound connections, the peer is its own source
		addr, err := NewNetAddressString(p.ListenAddr)
		if err != nil {
			// this should never happen
			log.Error("Error in AddPeer: invalid peer address", "addr", p.ListenAddr, "error", err)
			return
		}
		r.book.AddAddress(addr, addr)
	}
}
// AddPeer implements Reactor by adding peer to the address book (if inbound)
// or by requesting more addresses (if outbound).