mirror of https://github.com/status-im/nim-eth.git
more fixes
This commit is contained in:
parent
0424a66aa2
commit
ebabd6f76d
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue