mirror of
https://github.com/codex-storage/nim-codex-dht.git
synced 2025-01-24 19:00:42 +00:00
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 <csaba.kiraly@gmail.com>
This commit is contained in:
parent
63822e8356
commit
4b82bdc2f9
@ -338,7 +338,7 @@ proc handleFindNode(d: Protocol, fromId: NodeId, fromAddr: Address,
|
|||||||
# TODO: Still deduplicate also?
|
# TODO: Still deduplicate also?
|
||||||
if fn.distances.all(proc (x: uint16): bool = return x <= 256):
|
if fn.distances.all(proc (x: uint16): bool = return x <= 256):
|
||||||
d.sendNodes(fromId, fromAddr, reqId,
|
d.sendNodes(fromId, fromAddr, reqId,
|
||||||
d.routingTable.neighboursAtDistances(fn.distances, seenOnly = true))
|
d.routingTable.neighboursAtDistances(fn.distances, seenOnly = true, k = FindNodeResultLimit))
|
||||||
else:
|
else:
|
||||||
# At least one invalid distance, but the polite node we are, still respond
|
# At least one invalid distance, but the polite node we are, still respond
|
||||||
# with empty nodes.
|
# with empty nodes.
|
||||||
@ -347,7 +347,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))
|
d.routingTable.neighbours(fnf.target, seenOnly = true, k = FindNodeResultLimit))
|
||||||
# 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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user