fix(p2p): fix possible connectivity issue (#1996)

This commit is contained in:
Alvaro Revuelta 2023-09-08 13:36:26 +02:00 committed by GitHub
parent fc6194bb6b
commit 7d9d8a3fb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -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])

View File

@ -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())