mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 06:54:41 +00:00
rename private_peers to private_peer_ids to distinguish from peers
This commit is contained in:
+21
-2
@@ -74,6 +74,10 @@ type PEXReactorConfig struct {
|
||||
// Seeds is a list of addresses reactor may use
|
||||
// if it can't connect to peers in the addrbook.
|
||||
Seeds []string
|
||||
|
||||
// PrivatePeerIDs is a list of peer IDs, which must not be gossiped to other
|
||||
// peers.
|
||||
PrivatePeerIDs []string
|
||||
}
|
||||
|
||||
type _attemptsToDial struct {
|
||||
@@ -152,7 +156,9 @@ func (r *PEXReactor) AddPeer(p Peer) {
|
||||
// Let the ensurePeersRoutine handle asking for more
|
||||
// peers when we need - we don't trust inbound peers as much.
|
||||
addr := p.NodeInfo().NetAddress()
|
||||
r.book.AddAddress(addr, addr)
|
||||
if !isAddrPrivate(addr, r.config.PrivatePeerIDs) {
|
||||
r.book.AddAddress(addr, addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +257,10 @@ func (r *PEXReactor) ReceiveAddrs(addrs []*p2p.NetAddress, src Peer) error {
|
||||
|
||||
srcAddr := src.NodeInfo().NetAddress()
|
||||
for _, netAddr := range addrs {
|
||||
if netAddr != nil {
|
||||
if netAddr == nil {
|
||||
continue
|
||||
}
|
||||
if !isAddrPrivate(netAddr, r.config.PrivatePeerIDs) {
|
||||
r.book.AddAddress(netAddr, srcAddr)
|
||||
}
|
||||
}
|
||||
@@ -579,6 +588,16 @@ func (r *PEXReactor) attemptDisconnects() {
|
||||
}
|
||||
}
|
||||
|
||||
// isAddrPrivate returns true if addr is private.
|
||||
func isAddrPrivate(addr *p2p.NetAddress, privatePeerIDs []string) bool {
|
||||
for _, id := range privatePeerIDs {
|
||||
if string(addr.ID) == id {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Messages
|
||||
|
||||
|
||||
Reference in New Issue
Block a user