From bdf57381e35136f6cf01cb8bf2cb93a6bf8ab03f Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Sat, 8 Jul 2023 01:30:14 +0200 Subject: [PATCH] introduce FindNodeFastResultLimit We do not need that many responses with FindNodeFast, since the reposes can be ordered by distance Signed-off-by: Csaba Kiraly --- codexdht/private/eth/p2p/discoveryv5/protocol.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codexdht/private/eth/p2p/discoveryv5/protocol.nim b/codexdht/private/eth/p2p/discoveryv5/protocol.nim index c5b3f2f..b8af3a2 100644 --- a/codexdht/private/eth/p2p/discoveryv5/protocol.nim +++ b/codexdht/private/eth/p2p/discoveryv5/protocol.nim @@ -117,6 +117,7 @@ const LookupRequestLimit = 3 ## Amount of distances requested in a single Findnode ## message for a lookup or query FindNodeResultLimit = 16 ## Maximum amount of SPRs in the total Nodes messages + FindNodeFastResultLimit = 6 ## Maximum amount of SPRs in response to findNodeFast ## that will be processed MaxNodesPerMessage = 3 ## Maximum amount of SPRs per individual Nodes message RefreshInterval = 5.minutes ## Interval of launching a random query to @@ -347,7 +348,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, k = FindNodeResultLimit)) + d.routingTable.neighbours(fnf.target, seenOnly = true, k = FindNodeFastResultLimit)) # TODO: if known, maybe we should add exact target even if not yet "seen" proc handleTalkReq(d: Protocol, fromId: NodeId, fromAddr: Address, @@ -568,7 +569,7 @@ proc findNodeFast*(d: Protocol, toNode: Node, target: NodeId): let nodes = await d.waitNodes(toNode, reqId) if nodes.isOk: - let res = verifyNodesRecords(nodes.get(), toNode, FindNodeResultLimit) + let res = verifyNodesRecords(nodes.get(), toNode, FindNodeFastResultLimit) d.routingTable.setJustSeen(toNode) return ok(res) else: