Allow starting the discovery v5 bootstrap process without ENR records

This commit is contained in:
Zahary Karadjov 2020-02-05 13:28:23 +01:00 committed by zah
parent 1756f7b41f
commit 81e0ae12b0
1 changed files with 9 additions and 3 deletions

View File

@ -324,14 +324,20 @@ proc open*(d: Protocol) =
d.transp = newDatagramTransport(processClient, udata = d, local = ta)
asyncCheck d.revalidateLoop() # TODO: This loop has to be terminated on close()
proc addNode*(d: Protocol, r: Record) =
discard d.routingTable.addNode(newNode(r))
proc addNode*(d: Protocol, node: Node) =
discard d.routingTable.addNode(node)
template addNode*(d: Protocol, enode: ENode) =
addNode d, newNode(enode)
template addNode*(d: Protocol, r: Record) =
addNode d, newNode(r)
proc addNode*(d: Protocol, enr: EnrUri) =
var r: Record
let res = r.fromUri(enr)
doAssert(res)
discard d.routingTable.addNode(newNode(r))
discard d.addNode newNode(r)
proc randomNodes*(k: Protocol, count: int): seq[Node] =
k.routingTable.randomNodes(count)