From 4b82bdc2f9226933d547bb55253b1d73c18f0a26 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 19 Jun 2023 12:16:54 +0200 Subject: [PATCH] fix returning too many nodes when FindNodeResultLimit!=BUCKET_SIZE Code assumed these two values to be the same, resulting in reception errors. Signed-off-by: Csaba Kiraly --- codexdht/private/eth/p2p/discoveryv5/protocol.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codexdht/private/eth/p2p/discoveryv5/protocol.nim b/codexdht/private/eth/p2p/discoveryv5/protocol.nim index c3f0672..c5b3f2f 100644 --- a/codexdht/private/eth/p2p/discoveryv5/protocol.nim +++ b/codexdht/private/eth/p2p/discoveryv5/protocol.nim @@ -338,7 +338,7 @@ proc handleFindNode(d: Protocol, fromId: NodeId, fromAddr: Address, # TODO: Still deduplicate also? if fn.distances.all(proc (x: uint16): bool = return x <= 256): d.sendNodes(fromId, fromAddr, reqId, - d.routingTable.neighboursAtDistances(fn.distances, seenOnly = true)) + d.routingTable.neighboursAtDistances(fn.distances, seenOnly = true, k = FindNodeResultLimit)) else: # At least one invalid distance, but the polite node we are, still respond # with empty nodes. @@ -347,7 +347,7 @@ proc handleFindNode(d: Protocol, fromId: NodeId, fromAddr: Address, proc handleFindNodeFast(d: Protocol, fromId: NodeId, fromAddr: Address, fnf: FindNodeFastMessage, reqId: RequestId) = d.sendNodes(fromId, fromAddr, reqId, - d.routingTable.neighbours(fnf.target, seenOnly = true)) + d.routingTable.neighbours(fnf.target, seenOnly = true, k = FindNodeResultLimit)) # TODO: if known, maybe we should add exact target even if not yet "seen" proc handleTalkReq(d: Protocol, fromId: NodeId, fromAddr: Address,