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:
Csaba Kiraly 2023-09-12 11:23:24 +02:00
parent ec266ea478
commit 03c363e18d
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E

View File

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