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)
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)

View File

@ -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: