mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-02-27 21:53:16 +00:00
Adapt code and build to new libp2p
This commit is contained in:
parent
33f5f239bb
commit
36993b4817
@ -997,6 +997,7 @@ procSuite "Peer Manager":
|
||||
.build(),
|
||||
maxFailedAttempts = 1,
|
||||
storage = nil,
|
||||
maxConnections = 20,
|
||||
)
|
||||
|
||||
# Create 30 peers and add them to the peerstore
|
||||
@ -1063,6 +1064,7 @@ procSuite "Peer Manager":
|
||||
backoffFactor = 2,
|
||||
maxFailedAttempts = 10,
|
||||
storage = nil,
|
||||
maxConnections = 20,
|
||||
)
|
||||
var p1: PeerId
|
||||
require p1.init("QmeuZJbXrszW2jdT7GdduSjQskPU3S7vvGWKtKgDfkDvW" & "1")
|
||||
@ -1116,6 +1118,7 @@ procSuite "Peer Manager":
|
||||
.build(),
|
||||
maxFailedAttempts = 150,
|
||||
storage = nil,
|
||||
maxConnections = 20,
|
||||
)
|
||||
|
||||
# Should result in backoff > 1 week
|
||||
@ -1131,6 +1134,7 @@ procSuite "Peer Manager":
|
||||
.build(),
|
||||
maxFailedAttempts = 10,
|
||||
storage = nil,
|
||||
maxConnections = 20,
|
||||
)
|
||||
|
||||
let pm = PeerManager.new(
|
||||
@ -1144,6 +1148,7 @@ procSuite "Peer Manager":
|
||||
.build(),
|
||||
maxFailedAttempts = 5,
|
||||
storage = nil,
|
||||
maxConnections = 20,
|
||||
)
|
||||
|
||||
asyncTest "colocationLimit is enforced by pruneConnsByIp()":
|
||||
|
||||
@ -31,7 +31,9 @@ requires "nim >= 2.2.4",
|
||||
"results",
|
||||
"db_connector",
|
||||
"minilru",
|
||||
"ffi"
|
||||
"ffi",
|
||||
"lsquic",
|
||||
"jwt"
|
||||
|
||||
### Helper functions
|
||||
proc buildModule(filePath, params = "", lang = "c"): bool =
|
||||
|
||||
@ -209,6 +209,7 @@ proc build*(builder: WakuNodeBuilder): Result[WakuNode, string] =
|
||||
maxServicePeers = some(builder.maxServicePeers),
|
||||
colocationLimit = builder.colocationLimit,
|
||||
shardedPeerManagement = builder.shardAware,
|
||||
maxConnections = builder.switchMaxConnections.get(builders.MaxConnections),
|
||||
)
|
||||
|
||||
var node: WakuNode
|
||||
|
||||
@ -13,7 +13,6 @@ import
|
||||
libp2p/services/autorelayservice,
|
||||
libp2p/services/hpservice,
|
||||
libp2p/peerid,
|
||||
libp2p/discovery/rendezvousinterface,
|
||||
eth/keys,
|
||||
eth/p2p/discoveryv5/enr,
|
||||
presto,
|
||||
|
||||
@ -103,6 +103,7 @@ type PeerManager* = ref object of RootObj
|
||||
onConnectionChange*: ConnectionChangeHandler
|
||||
online: bool ## state managed by online_monitor module
|
||||
getShards: GetShards
|
||||
maxConnections: int
|
||||
|
||||
#~~~~~~~~~~~~~~~~~~~#
|
||||
# Helper Functions #
|
||||
@ -748,7 +749,6 @@ proc logAndMetrics(pm: PeerManager) {.async.} =
|
||||
var peerStore = pm.switch.peerStore
|
||||
# log metrics
|
||||
let (inRelayPeers, outRelayPeers) = pm.connectedPeers(WakuRelayCodec)
|
||||
let maxConnections = pm.switch.connManager.inSema.size
|
||||
let notConnectedPeers =
|
||||
peerStore.getDisconnectedPeers().mapIt(RemotePeerInfo.init(it.peerId, it.addrs))
|
||||
let outsideBackoffPeers = notConnectedPeers.filterIt(pm.canBeConnected(it.peerId))
|
||||
@ -758,7 +758,7 @@ proc logAndMetrics(pm: PeerManager) {.async.} =
|
||||
info "Relay peer connections",
|
||||
inRelayConns = $inRelayPeers.len & "/" & $pm.inRelayPeersTarget,
|
||||
outRelayConns = $outRelayPeers.len & "/" & $pm.outRelayPeersTarget,
|
||||
totalConnections = $totalConnections & "/" & $maxConnections,
|
||||
totalConnections = $totalConnections & "/" & $pm.maxConnections,
|
||||
notConnectedPeers = notConnectedPeers.len,
|
||||
outsideBackoffPeers = outsideBackoffPeers.len
|
||||
|
||||
@ -1048,9 +1048,9 @@ proc new*(
|
||||
maxFailedAttempts = MaxFailedAttempts,
|
||||
colocationLimit = DefaultColocationLimit,
|
||||
shardedPeerManagement = false,
|
||||
maxConnections: int = MaxConnections,
|
||||
): PeerManager {.gcsafe.} =
|
||||
let capacity = switch.peerStore.capacity
|
||||
let maxConnections = switch.connManager.inSema.size
|
||||
if maxConnections > capacity:
|
||||
error "Max number of connections can't be greater than PeerManager capacity",
|
||||
capacity = capacity, maxConnections = maxConnections
|
||||
@ -1099,6 +1099,7 @@ proc new*(
|
||||
colocationLimit: colocationLimit,
|
||||
shardedPeerManagement: shardedPeerManagement,
|
||||
online: true,
|
||||
maxConnections: maxConnections,
|
||||
)
|
||||
|
||||
proc peerHook(
|
||||
|
||||
@ -8,7 +8,6 @@ import
|
||||
stew/byteutils,
|
||||
libp2p/protocols/rendezvous,
|
||||
libp2p/protocols/rendezvous/protobuf,
|
||||
libp2p/discovery/discoverymngr,
|
||||
libp2p/utils/semaphore,
|
||||
libp2p/utils/offsettedseq,
|
||||
libp2p/crypto/curve25519,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user