diff --git a/eth/p2p.nim b/eth/p2p.nim index e50cdfc..0ca3a29 100644 --- a/eth/p2p.nim +++ b/eth/p2p.nim @@ -141,7 +141,7 @@ iterator randomPeers*(node: EthereumNode, maxPeers: int): Peer = yield peers[i] proc randomPeer*(node: EthereumNode): Peer = - let peerIdx = random(node.peerPool.connectedNodes.len) + let peerIdx = rand(node.peerPool.connectedNodes.len) var i = 0 for peer in node.peers: if i == peerIdx: return peer diff --git a/eth/p2p/peer_pool.nim b/eth/p2p/peer_pool.nim index 10d19bb..5dbaf9d 100644 --- a/eth/p2p/peer_pool.nim +++ b/eth/p2p/peer_pool.nim @@ -105,7 +105,7 @@ proc lookupRandomNode(p: PeerPool) {.async.} = proc getRandomBootnode(p: PeerPool): Option[Node] = if p.discovery.bootstrapNodes.len != 0: - result = option(p.discovery.bootstrapNodes.rand()) + result = option(p.discovery.bootstrapNodes.sample()) proc addPeer*(pool: PeerPool, peer: Peer) {.gcsafe.} = doAssert(peer.remote notin pool.connectedNodes)