p2p: limit the number of incoming connections

to p2p.max_num_inbound_peers + len(p2p.unconditional_peer_ids)
This commit is contained in:
Anton Kaliaev
2020-04-03 15:37:20 +04:00
committed by Tess Rinearson
parent ff87bd912f
commit e2d6859afd
3 changed files with 64 additions and 2 deletions

View File

@@ -471,6 +471,11 @@ func createTransport(
}
p2p.MultiplexTransportConnFilters(connFilters...)(transport)
// Limit the number of incoming connections.
max := config.P2P.MaxNumInboundPeers + len(splitAndTrimEmpty(config.P2P.UnconditionalPeerIDs, ",", " "))
p2p.MultiplexTransportMaxIncomingConnections(max)(transport)
return transport, peerFilters
}