2020-08-26 12:20:04 +00:00
|
|
|
import
|
|
|
|
chronos,
|
2020-09-01 02:09:54 +00:00
|
|
|
eth/[p2p, async_utils], eth/p2p/peer_pool
|
2020-08-26 12:20:04 +00:00
|
|
|
|
|
|
|
proc setBootNodes*(nodes: openArray[string]): seq[ENode] =
|
|
|
|
result = newSeqOfCap[ENode](nodes.len)
|
|
|
|
for nodeId in nodes:
|
|
|
|
# TODO: something more user friendly than an expect
|
|
|
|
result.add(ENode.fromString(nodeId).expect("correct node"))
|
|
|
|
|
|
|
|
proc connectToNodes*(node: EthereumNode, nodes: openArray[string]) =
|
|
|
|
for nodeId in nodes:
|
|
|
|
# TODO: something more user friendly than an assert
|
|
|
|
let whisperENode = ENode.fromString(nodeId).expect("correct node")
|
|
|
|
|
|
|
|
traceAsyncErrors node.peerPool.connectToNode(newNode(whisperENode))
|