mirror of https://github.com/status-im/nim-eth.git
Let talkreq directly return the seq[byte] for easier API (#384)
This commit is contained in:
parent
dd02d1be23
commit
9bc4fa366a
|
@ -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"])
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue