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:
parent
4b82bdc2f9
commit
bdf57381e3
|
@ -117,6 +117,7 @@ const
|
||||||
LookupRequestLimit = 3 ## Amount of distances requested in a single Findnode
|
LookupRequestLimit = 3 ## Amount of distances requested in a single Findnode
|
||||||
## message for a lookup or query
|
## message for a lookup or query
|
||||||
FindNodeResultLimit = 16 ## Maximum amount of SPRs in the total Nodes messages
|
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
|
## that will be processed
|
||||||
MaxNodesPerMessage = 3 ## Maximum amount of SPRs per individual Nodes message
|
MaxNodesPerMessage = 3 ## Maximum amount of SPRs per individual Nodes message
|
||||||
RefreshInterval = 5.minutes ## Interval of launching a random query to
|
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,
|
proc handleFindNodeFast(d: Protocol, fromId: NodeId, fromAddr: Address,
|
||||||
fnf: FindNodeFastMessage, reqId: RequestId) =
|
fnf: FindNodeFastMessage, reqId: RequestId) =
|
||||||
d.sendNodes(fromId, fromAddr, reqId,
|
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"
|
# TODO: if known, maybe we should add exact target even if not yet "seen"
|
||||||
|
|
||||||
proc handleTalkReq(d: Protocol, fromId: NodeId, fromAddr: Address,
|
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)
|
let nodes = await d.waitNodes(toNode, reqId)
|
||||||
|
|
||||||
if nodes.isOk:
|
if nodes.isOk:
|
||||||
let res = verifyNodesRecords(nodes.get(), toNode, FindNodeResultLimit)
|
let res = verifyNodesRecords(nodes.get(), toNode, FindNodeFastResultLimit)
|
||||||
d.routingTable.setJustSeen(toNode)
|
d.routingTable.setJustSeen(toNode)
|
||||||
return ok(res)
|
return ok(res)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue