From 0820dbba46aa1ac8b9f4ff93cd4d79bad016484d Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Tue, 15 Dec 2020 12:41:53 +0100 Subject: [PATCH] Use one instead of deprecated oneIndex (#317) --- eth/p2p/discoveryv5/node.nim | 2 +- eth/p2p/discoveryv5/protocol.nim | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/eth/p2p/discoveryv5/node.nim b/eth/p2p/discoveryv5/node.nim index 88526a5..d8d045e 100644 --- a/eth/p2p/discoveryv5/node.nim +++ b/eth/p2p/discoveryv5/node.nim @@ -52,7 +52,7 @@ proc updateNode*(n: Node, pk: PrivateKey, ip: Option[ValidIpAddress], ? n.record.update(pk, ip, tcpPort, udpPort, extraFields) if ip.isSome(): - let a = Address(ip: ip.get(), port: Port(udpPort)) + let a = Address(ip: ip.get(), port: udpPort) n.address = some(a) else: n.address = none(Address) diff --git a/eth/p2p/discoveryv5/protocol.nim b/eth/p2p/discoveryv5/protocol.nim index 91618f4..a944f0b 100644 --- a/eth/p2p/discoveryv5/protocol.nim +++ b/eth/p2p/discoveryv5/protocol.nim @@ -672,11 +672,16 @@ proc lookup*(d: Protocol, target: NodeId): Future[seq[Node]] if pendingQueries.len == 0: break - let idx = await oneIndex(pendingQueries) - trace "Got discv5 lookup response", idx + let query = await one(pendingQueries) + trace "Got discv5 lookup query response" - let nodes = pendingQueries[idx].read - pendingQueries.del(idx) + let index = pendingQueries.find(query) + if index != -1: + pendingQueries.del(index) + else: + error "Resulting query should have beeen in the pending queries" + + let nodes = query.read for n in nodes: if not seen.containsOrIncl(n.id): if result.len < BUCKET_SIZE: