Let talkreq directly return the seq[byte] for easier API (#384)

This commit is contained in:
Kim De Mey 2021-07-30 16:04:14 +02:00 committed by GitHub
parent dd02d1be23
commit 9bc4fa366a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -633,7 +633,7 @@ proc findNode*(d: Protocol, toNode: Node, distances: seq[uint16]):
return err(nodes.error)
proc talkreq*(d: Protocol, toNode: Node, protocol, request: seq[byte]):
Future[DiscResult[TalkRespMessage]] {.async.} =
Future[DiscResult[seq[byte]]] {.async.} =
## Send a discovery talkreq message.
##
## Returns the received talkresp message or an error.
@ -644,7 +644,7 @@ proc talkreq*(d: Protocol, toNode: Node, protocol, request: seq[byte]):
if resp.isSome():
if resp.get().kind == talkresp:
d.routingTable.setJustSeen(toNode)
return ok(resp.get().talkresp)
return ok(resp.get().talkresp.response)
else:
d.replaceNode(toNode)
discovery_message_requests_outgoing.inc(labelValues = ["invalid_response"])

View File

@ -632,7 +632,7 @@ procSuite "Discovery v5 Tests":
check:
talkresp.isOk()
talkresp.get().response.len == 0
talkresp.get().len == 0
await node1.closeWait()
await node2.closeWait()
@ -657,7 +657,7 @@ procSuite "Discovery v5 Tests":
check:
talkresp.isOk()
talkresp.get().response == "hello".toBytes()
talkresp.get() == "hello".toBytes()
await node1.closeWait()
await node2.closeWait()