fix deprecated 'rand' (#259)

This commit is contained in:
Miran 2020-06-24 16:06:07 +02:00 committed by GitHub
parent 61feae0f21
commit 0424a66aa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -496,9 +496,9 @@ proc randomNodes*(k: KademliaProtocol, count: int): seq[Node] =
# insignificant compared to the time it takes for the network roundtrips when connecting
# to nodes.
while len(seen) < count:
let bucket = k.routing.buckets.rand()
let bucket = k.routing.buckets.sample()
if bucket.nodes.len != 0:
let node = bucket.nodes.rand()
let node = bucket.nodes.sample()
if node notin seen:
result.add(node)
seen.incl(node)