Skip to content

Commit

Permalink
chore: update type mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
darshankabariya committed Dec 16, 2024
1 parent 371cf53 commit d5a12ef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
14 changes: 7 additions & 7 deletions waku/factory/external_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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* {.
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion waku/factory/node_factory.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
8 changes: 2 additions & 6 deletions waku/node/peer_manager/peer_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d5a12ef

Please sign in to comment.