From 23e20a2f1c2ce8c08236333cf41dd41d98b1fd2a Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 12 Sep 2022 18:41:44 -0600 Subject: [PATCH] bad merge --- .../private/eth/p2p/discoveryv5/protocol.nim | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libp2pdht/private/eth/p2p/discoveryv5/protocol.nim b/libp2pdht/private/eth/p2p/discoveryv5/protocol.nim index 178c25b..ae8cf81 100644 --- a/libp2pdht/private/eth/p2p/discoveryv5/protocol.nim +++ b/libp2pdht/private/eth/p2p/discoveryv5/protocol.nim @@ -1046,6 +1046,33 @@ proc newProtocol*( result.transport = newTransport(result, privKey, node, bindPort, bindIp, rng) +proc newProtocol*( + privKey: PrivateKey, + bindPort: Port, + record: SignedPeerRecord, + bootstrapRecords: openArray[SignedPeerRecord] = [], + bindIp = IPv4_any(), + config = defaultDiscoveryConfig, + rng = newRng()): + Protocol = + info "Discovery SPR initialized", seqNum = record.seqNum, uri = toURI(record) + let node = newNode(record).expect("Properly initialized record") + + # TODO Consider whether this should be a Defect + doAssert rng != nil, "RNG initialization failed" + + result = Protocol( + privateKey: privKey, + localNode: node, + bootstrapRecords: @bootstrapRecords, + ipVote: IpVote.init(), + enrAutoUpdate: false, #TODO this should be removed from nim-libp2p-dht + routingTable: RoutingTable.init( + node, config.bitsPerHop, config.tableIpLimits, rng), + rng: rng) + + result.transport = newTransport(result, privKey, node, bindPort, bindIp, rng) + proc open*(d: Protocol) {.raises: [Defect, CatchableError].} = info "Starting discovery node", node = d.localNode