mirror of
https://github.com/status-im/nim-libp2p.git
synced 2025-02-21 17:18:35 +00:00
fix: limit
This commit is contained in:
parent
43d1ce2ef1
commit
ea7d6c8b3a
@ -558,7 +558,7 @@ proc requestLocally*(rdv: RendezVous, ns: string): seq[PeerRecord] =
|
||||
@[]
|
||||
|
||||
proc request*(
|
||||
rdv: RendezVous, ns: string, limit: int = DiscoverLimit.int, peers: seq[PeerId]
|
||||
rdv: RendezVous, ns: string, limit: uint64 = DiscoverLimit, peers: seq[PeerId]
|
||||
): Future[seq[PeerRecord]] {.async.} =
|
||||
## This async procedure discovers and returns peers for a given namespace
|
||||
## by sending requests and processing responses. It limits the number of
|
||||
@ -566,14 +566,12 @@ proc request*(
|
||||
##
|
||||
var
|
||||
s: Table[PeerId, (PeerRecord, Register)]
|
||||
limit: uint64
|
||||
d = Discover(ns: ns)
|
||||
|
||||
if limit <= 0 or limit > DiscoverLimit.int:
|
||||
if limit > DiscoverLimit.int:
|
||||
raise newException(RendezVousError, "Invalid limit")
|
||||
if ns.len notin 0 .. 255:
|
||||
raise newException(RendezVousError, "Invalid namespace")
|
||||
limit = limit.uint64
|
||||
proc requestPeer(peer: PeerId) {.async.} =
|
||||
let conn = await rdv.switch.dial(peer, RendezVousCodec)
|
||||
defer:
|
||||
@ -641,7 +639,7 @@ proc request*(
|
||||
return toSeq(s.values()).mapIt(it[0])
|
||||
|
||||
proc request*(
|
||||
rdv: RendezVous, ns: string, limit: int = DiscoverLimit.int
|
||||
rdv: RendezVous, ns: string, limit: uint64 = DiscoverLimit
|
||||
): Future[seq[PeerRecord]] {.async.} =
|
||||
await rdv.request(ns, limit, rdv.peers)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user