From 81e0ae12b06aa7398968946526184f7268b8faa3 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 5 Feb 2020 13:28:23 +0100 Subject: [PATCH] Allow starting the discovery v5 bootstrap process without ENR records --- eth/p2p/discoveryv5/protocol.nim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/eth/p2p/discoveryv5/protocol.nim b/eth/p2p/discoveryv5/protocol.nim index 2469d62..1b05b5c 100644 --- a/eth/p2p/discoveryv5/protocol.nim +++ b/eth/p2p/discoveryv5/protocol.nim @@ -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)