Skip to content

Commit

Permalink
Div target per shard count
Browse files Browse the repository at this point in the history
  • Loading branch information
SionoiS committed Oct 30, 2023
1 parent 2947dab commit b79983c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions waku/node/peer_manager/peer_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,13 @@ proc manageRelayPeers*(pm: PeerManager) {.async.} =
let connectedOutPeers = peers.filterIt(
pm.peerStore.isConnected(it.peerId) and it.direction == Outbound)

let outPeerDiff = pm.outRelayPeersTarget - connectedOutPeers.len
let inPeerDiff = pm.inRelayPeersTarget - connectedInPeers.len
# 1/3 of relay connection divided by number of shards minus current ones
let outPeerDiff =
pm.outRelayPeersTarget div pm.wakuMetadata.shards.len - connectedOutPeers.len

# 2/3 of relay connections divided by number of shards minus current ones
let inPeerDiff =
pm.inRelayPeersTarget div pm.wakuMetadata.shards.len - connectedInPeers.len

if inPeerDiff <= 0:
peersToDisconnect += abs(inPeerDiff)
Expand Down

0 comments on commit b79983c

Please sign in to comment.