mirror of
https://github.com/logos-storage/logos-storage-nim-dht.git
synced 2026-01-04 06:23:05 +00:00
Merge pull request #94 from codex-storage/feature-FindNodeFastResultLimit
Add separate limit for results returned in FindNodeFast
This commit is contained in:
commit
fef297c622
@ -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…
x
Reference in New Issue
Block a user