From 9bc4fa366af2f75dd2c8608964dc6dc3614b3f81 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Fri, 30 Jul 2021 16:04:14 +0200 Subject: [PATCH] Let talkreq directly return the seq[byte] for easier API (#384) --- eth/p2p/discoveryv5/protocol.nim | 4 ++-- tests/p2p/test_discoveryv5.nim | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eth/p2p/discoveryv5/protocol.nim b/eth/p2p/discoveryv5/protocol.nim index 4712b6e..4dbc1c5 100644 --- a/eth/p2p/discoveryv5/protocol.nim +++ b/eth/p2p/discoveryv5/protocol.nim @@ -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"]) diff --git a/tests/p2p/test_discoveryv5.nim b/tests/p2p/test_discoveryv5.nim index 26340e5..d6521b8 100644 --- a/tests/p2p/test_discoveryv5.nim +++ b/tests/p2p/test_discoveryv5.nim @@ -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()