mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-16 14:41:21 +00:00
p2p: MinNumOutboundPeers. Closes #1501
This commit is contained in:
@ -31,7 +31,7 @@ const (
|
|||||||
|
|
||||||
// ensure we have enough peers
|
// ensure we have enough peers
|
||||||
defaultEnsurePeersPeriod = 30 * time.Second
|
defaultEnsurePeersPeriod = 30 * time.Second
|
||||||
defaultMinNumOutboundPeers = 10
|
defaultMinNumOutboundPeers = p2p.DefaultMinNumOutboundPeers
|
||||||
|
|
||||||
// Seed/Crawler constants
|
// Seed/Crawler constants
|
||||||
|
|
||||||
|
@ -26,6 +26,10 @@ const (
|
|||||||
// ie. 3**10 = 16hrs
|
// ie. 3**10 = 16hrs
|
||||||
reconnectBackOffAttempts = 10
|
reconnectBackOffAttempts = 10
|
||||||
reconnectBackOffBaseSeconds = 3
|
reconnectBackOffBaseSeconds = 3
|
||||||
|
|
||||||
|
// keep at least this many outbound peers
|
||||||
|
// TODO: move to config
|
||||||
|
DefaultMinNumOutboundPeers = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -458,7 +462,8 @@ func (sw *Switch) listenerRoutine(l Listener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ignore connection if we already have enough
|
// ignore connection if we already have enough
|
||||||
maxPeers := sw.config.MaxNumPeers
|
// leave room for MinNumOutboundPeers
|
||||||
|
maxPeers := sw.config.MaxNumPeers - DefaultMinNumOutboundPeers
|
||||||
if maxPeers <= sw.peers.Size() {
|
if maxPeers <= sw.peers.Size() {
|
||||||
sw.Logger.Info("Ignoring inbound connection: already have enough peers", "address", inConn.RemoteAddr().String(), "numPeers", sw.peers.Size(), "max", maxPeers)
|
sw.Logger.Info("Ignoring inbound connection: already have enough peers", "address", inConn.RemoteAddr().String(), "numPeers", sw.peers.Size(), "max", maxPeers)
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user