From c078f85e48f20bc123a4c156b806bfa1a6014ae3 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Tue, 7 Sep 2021 10:49:18 +0200 Subject: [PATCH] Expose id and address of talkreq sender (#393) --- 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 a1a0852..51dd841 100644 --- a/eth/p2p/discoveryv5/protocol.nim +++ b/eth/p2p/discoveryv5/protocol.nim @@ -140,7 +140,7 @@ type node: Node message: seq[byte] - TalkProtocolHandler* = proc(p: TalkProtocol, request: seq[byte]): seq[byte] + TalkProtocolHandler* = proc(p: TalkProtocol, request: seq[byte], fromId: NodeId, fromUdpAddress: Address): seq[byte] {.gcsafe, raises: [Defect].} TalkProtocol* = ref object of RootObj @@ -318,7 +318,7 @@ proc handleTalkReq(d: Protocol, fromId: NodeId, fromAddr: Address, TalkRespMessage(response: @[]) else: TalkRespMessage(response: talkProtocol.protocolHandler(talkProtocol, - talkreq.request)) + talkreq.request, fromId, fromAddr)) let (data, _) = encodeMessagePacket(d.rng[], d.codec, fromId, fromAddr, encodeMessage(talkresp, reqId)) diff --git a/tests/p2p/test_discoveryv5.nim b/tests/p2p/test_discoveryv5.nim index d6521b8..0464db6 100644 --- a/tests/p2p/test_discoveryv5.nim +++ b/tests/p2p/test_discoveryv5.nim @@ -645,7 +645,7 @@ procSuite "Discovery v5 Tests": rng, PrivateKey.random(rng[]), localAddress(20303)) talkProtocol = "echo".toBytes() - proc handler(protocol: TalkProtocol, request: seq[byte]): seq[byte] + proc handler(protocol: TalkProtocol, request: seq[byte], fromId: NodeId, fromUdpAddress: Address): seq[byte] {.gcsafe, raises: [Defect].} = request @@ -670,7 +670,7 @@ procSuite "Discovery v5 Tests": rng, PrivateKey.random(rng[]), localAddress(20303)) talkProtocol = "echo".toBytes() - proc handler(protocol: TalkProtocol, request: seq[byte]): seq[byte] + proc handler(protocol: TalkProtocol, request: seq[byte], fromId: NodeId, fromUdpAddress: Address): seq[byte] {.gcsafe, raises: [Defect].} = request