introduce FindNodeFastResultLimit

We do not need that many responses with FindNodeFast, since the
reposes can be ordered by distance

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-07-08 01:30:14 +02:00
parent 4b82bdc2f9
commit bdf57381e3
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 3 additions and 2 deletions

View File

@ -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: