Skip to content

Commit

Permalink
Merge c93e0a8 into 3321fd0
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer authored Oct 16, 2024
2 parents 3321fd0 + c93e0a8 commit 9fd30c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion waku/factory/node_factory.nim
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ proc startNode*(

# retrieve px peers and add the to the peer store
if conf.peerExchangeNode != "":
let desiredOutDegree = node.wakuRelay.parameters.d.uint64()
var desiredOutDegree = DefaultPXNumPeersReq
if not node.wakuRelay.isNil() and node.wakuRelay.parameters.d.uint64() > 0:
desiredOutDegree = node.wakuRelay.parameters.d.uint64()
(await node.fetchPeerExchangePeers(desiredOutDegree)).isOkOr:
error "error while fetching peers from peer exchange", error = error
quit(QuitFailure)
Expand Down
7 changes: 4 additions & 3 deletions waku/waku_peer_exchange/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const
# TODO what is the expected size of a PX message? As currently specified, it can contain an arbitary number of ENRs...
MaxPeersCacheSize = 60
CacheRefreshInterval = 10.minutes
DefaultPXNumPeersReq* = 5.uint64()

WakuPeerExchangeCodec* = "/vac/waku/peer-exchange/2.0.0-alpha1"

Expand All @@ -57,7 +58,7 @@ type
requestRateLimiter*: RequestRateLimiter

proc request*(
wpx: WakuPeerExchange, numPeers: uint64, conn: Connection
wpx: WakuPeerExchange, numPeers = DefaultPXNumPeersReq, conn: Connection
): Future[WakuPeerExchangeResult[PeerExchangeResponse]] {.async: (raises: []).} =
let rpc = PeerExchangeRpc.makeRequest(numPeers)

Expand Down Expand Up @@ -99,7 +100,7 @@ proc request*(
return ok(decodedBuff.get().response)

proc request*(
wpx: WakuPeerExchange, numPeers: uint64, peer: RemotePeerInfo
wpx: WakuPeerExchange, numPeers = DefaultPXNumPeersReq, peer: RemotePeerInfo
): Future[WakuPeerExchangeResult[PeerExchangeResponse]] {.async: (raises: []).} =
try:
let connOpt = await wpx.peerManager.dialPeer(peer, WakuPeerExchangeCodec)
Expand All @@ -120,7 +121,7 @@ proc request*(
)

proc request*(
wpx: WakuPeerExchange, numPeers: uint64
wpx: WakuPeerExchange, numPeers = DefaultPXNumPeersReq
): Future[WakuPeerExchangeResult[PeerExchangeResponse]] {.async: (raises: []).} =
let peerOpt = wpx.peerManager.selectPeer(WakuPeerExchangeCodec)
if peerOpt.isNone():
Expand Down

0 comments on commit 9fd30c5

Please sign in to comment.