more fixes

This commit is contained in:
narimiran 2020-06-24 16:31:44 +02:00 committed by Kim De Mey
parent 0424a66aa2
commit ebabd6f76d
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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)