From cae81ce43d4eea6357c4edf17ac5ffa1fe21e123 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Wed, 13 Jul 2022 17:08:29 -0400 Subject: [PATCH] p2p: configure max connected for non-legacy as well --- node/setup.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/node/setup.go b/node/setup.go index e94e85c78..e39408f58 100644 --- a/node/setup.go +++ b/node/setup.go @@ -441,12 +441,23 @@ func createConsensusReactor( } func createTransport(logger log.Logger, cfg *config.Config) *p2p.MConnTransport { + var maxAccepted uint32 + switch { + case cfg.P2P.MaxConnections > 0 && !cfg.P2P.UseLegacy: + maxAccepted = uint32(cfg.P2P.MaxConnections) + + uint32(len(tmstrings.SplitAndTrimEmpty(cfg.P2P.UnconditionalPeerIDs, ",", " "))) + + case cfg.P2P.MaxNumInboundPeers > 0: + maxAccepted = uint32(cfg.P2P.MaxNumInboundPeers) + + uint32(len(tmstrings.SplitAndTrimEmpty(cfg.P2P.UnconditionalPeerIDs, ",", " "))) + default: + maxAccepted = 0 + } + return p2p.NewMConnTransport( logger, p2p.MConnConfig(cfg.P2P), []*p2p.ChannelDescriptor{}, p2p.MConnTransportOptions{ - MaxAcceptedConnections: uint32(cfg.P2P.MaxNumInboundPeers + - len(tmstrings.SplitAndTrimEmpty(cfg.P2P.UnconditionalPeerIDs, ",", " ")), - ), + MaxAcceptedConnections: maxAccepted, }, ) }