diff --git a/waku/factory/external_config.nim b/waku/factory/external_config.nim index 761934d9a6..fd2bba64b0 100644 --- a/waku/factory/external_config.nim +++ b/waku/factory/external_config.nim @@ -197,13 +197,6 @@ type WakuNodeConf* = object desc: "Maximum allowed number of libp2p connections.", defaultValue: 50, name: "max-connections" - .}: uint16 - - colocationLimit* {. - desc: - "Max num allowed peers from the same IP. Set it to 0 to remove the limitation.", - defaultValue: defaultColocationLimit(), - name: "ip-colocation-limit" .}: int relayServiceRatio* {. @@ -212,6 +205,13 @@ type WakuNodeConf* = object defaultValue: 2.33 # 70:30 ratio of relay to service peers .}: float64 + colocationLimit* {. + desc: + "Max num allowed peers from the same IP. Set it to 0 to remove the limitation.", + defaultValue: defaultColocationLimit(), + name: "ip-colocation-limit" + .}: int + peerStoreCapacity* {. desc: "Maximum stored peers in the peerstore.", name: "peer-store-capacity" .}: Option[int] diff --git a/waku/factory/node_factory.nim b/waku/factory/node_factory.nim index a9d5a66a9d..12af8558f4 100644 --- a/waku/factory/node_factory.nim +++ b/waku/factory/node_factory.nim @@ -102,7 +102,7 @@ proc initNode( ) builder.withColocationLimit(conf.colocationLimit) builder.withPeerManagerConfig( - maxConnections = int(conf.maxConnections), + maxConnections = conf.maxConnections, relayServiceRatio = conf.relayServiceRatio, shardAware = conf.relayShardedPeerManagement, ) diff --git a/waku/node/peer_manager/peer_manager.nim b/waku/node/peer_manager/peer_manager.nim index b1bcbee6d8..745454ed7c 100644 --- a/waku/node/peer_manager/peer_manager.nim +++ b/waku/node/peer_manager/peer_manager.nim @@ -983,12 +983,8 @@ proc new*( Defect, "Max number of connections can't be greater than PeerManager capacity" ) - var maxRelayPeers = 0 - var maxServicePeers = 0 - - let ratio = relayServiceRatio - maxServicePeers = int(float(maxConnections) / (1 + ratio)) - maxRelayPeers = maxConnections - maxServicePeers + let maxServicePeers = int(float(maxConnections) / (1 + relayServiceRatio)) + let maxRelayPeers = maxConnections - maxServicePeers let outRelayPeersTarget = maxRelayPeers div 3 let inRelayPeersTarget = maxRelayPeers - outRelayPeersTarget