mirror of
https://github.com/logos-storage/logos-storage-nim-dht.git
synced 2026-03-30 07:43:10 +00:00
fix addValue not enough nodes
addValue cycle should consider number of nodes found. Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
ec266ea478
commit
03c363e18d
@ -871,7 +871,9 @@ proc addValue*(
|
||||
# TODO: lookup is specified as not returning local, even if that is the closest. Is this OK?
|
||||
if res.len == 0:
|
||||
res.add(d.localNode)
|
||||
for toNode in res[0 ..< ValueReplication]:
|
||||
if res.len < ValueReplication:
|
||||
trace "addValue lookup did not return enough nodes", key=cId, len=res.len, ValueReplication
|
||||
for toNode in res[0 ..< min(ValueReplication, res.len)]:
|
||||
if toNode != d.localNode:
|
||||
let reqId = RequestId.init(d.rng[])
|
||||
d.sendRequest(toNode, AddValueMessage(cId: cId, value: value), reqId)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user