Use one instead of deprecated oneIndex (#317)

This commit is contained in:
Kim De Mey 2020-12-15 12:41:53 +01:00 committed by GitHub
parent d024ea8e85
commit 0820dbba46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -52,7 +52,7 @@ proc updateNode*(n: Node, pk: PrivateKey, ip: Option[ValidIpAddress],
? n.record.update(pk, ip, tcpPort, udpPort, extraFields) ? n.record.update(pk, ip, tcpPort, udpPort, extraFields)
if ip.isSome(): if ip.isSome():
let a = Address(ip: ip.get(), port: Port(udpPort)) let a = Address(ip: ip.get(), port: udpPort)
n.address = some(a) n.address = some(a)
else: else:
n.address = none(Address) n.address = none(Address)

View File

@ -672,11 +672,16 @@ proc lookup*(d: Protocol, target: NodeId): Future[seq[Node]]
if pendingQueries.len == 0: if pendingQueries.len == 0:
break break
let idx = await oneIndex(pendingQueries) let query = await one(pendingQueries)
trace "Got discv5 lookup response", idx trace "Got discv5 lookup query response"
let nodes = pendingQueries[idx].read let index = pendingQueries.find(query)
pendingQueries.del(idx) 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: for n in nodes:
if not seen.containsOrIncl(n.id): if not seen.containsOrIncl(n.id):
if result.len < BUCKET_SIZE: if result.len < BUCKET_SIZE: