mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-28 15:00:57 +00:00
fix(p2p): fix possible connectivity issue (#1996)
This commit is contained in:
parent
fc6194bb6b
commit
7d9d8a3fb4
@ -53,7 +53,7 @@ const
|
||||
ConnectivityLoopInterval = chronos.seconds(15)
|
||||
|
||||
# How often the peer store is pruned
|
||||
PrunePeerStoreInterval = chronos.minutes(5)
|
||||
PrunePeerStoreInterval = chronos.minutes(10)
|
||||
|
||||
# How often metrics and logs are shown/updated
|
||||
LogAndMetricsInterval = chronos.minutes(3)
|
||||
@ -583,15 +583,16 @@ proc connectToRelayPeers*(pm: PeerManager) {.async.} =
|
||||
let totalRelayPeers = inRelayPeers.len + outRelayPeers.len
|
||||
let inPeersTarget = maxConnections - pm.outRelayPeersTarget
|
||||
|
||||
if inRelayPeers.len > pm.inRelayPeersTarget:
|
||||
await pm.pruneInRelayConns(inRelayPeers.len - pm.inRelayPeersTarget)
|
||||
# TODO: Temporally disabled. Might be causing connection issues
|
||||
#if inRelayPeers.len > pm.inRelayPeersTarget:
|
||||
# await pm.pruneInRelayConns(inRelayPeers.len - pm.inRelayPeersTarget)
|
||||
|
||||
if outRelayPeers.len >= pm.outRelayPeersTarget:
|
||||
return
|
||||
|
||||
let notConnectedPeers = pm.peerStore.getNotConnectedPeers().mapIt(RemotePeerInfo.init(it.peerId, it.addrs))
|
||||
let outsideBackoffPeers = notConnectedPeers.filterIt(pm.canBeConnected(it.peerId))
|
||||
let numPeersToConnect = min(min(maxConnections - totalRelayPeers, outsideBackoffPeers.len), MaxParalelDials)
|
||||
let numPeersToConnect = min(outsideBackoffPeers.len, MaxParalelDials)
|
||||
|
||||
await pm.connectToNodes(outsideBackoffPeers[0..<numPeersToConnect])
|
||||
|
||||
|
@ -101,7 +101,7 @@ proc newWakuSwitch*(
|
||||
if peerStoreCapacity.isSome():
|
||||
b = b.withPeerStore(peerStoreCapacity.get())
|
||||
else:
|
||||
let defaultPeerStoreCapacity = int(round(float64(maxConnections)*1.25))
|
||||
let defaultPeerStoreCapacity = int(maxConnections)*5
|
||||
b = b.withPeerStore(defaultPeerStoreCapacity)
|
||||
if agentString.isSome():
|
||||
b = b.withAgentVersion(agentString.get())
|
||||
|
Loading…
x
Reference in New Issue
Block a user