mirror of
https://github.com/logos-storage/logos-storage-nim-dht.git
synced 2026-01-07 16:03:09 +00:00
add ValueReplication cound for addValue
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
bfcf6e6443
commit
55aa70c78a
@ -129,6 +129,7 @@ const
|
|||||||
ResponseTimeout* = 4.seconds ## timeout for the response of a request-response
|
ResponseTimeout* = 4.seconds ## timeout for the response of a request-response
|
||||||
MaxProvidersEntries* = 1_000_000 # one million records
|
MaxProvidersEntries* = 1_000_000 # one million records
|
||||||
MaxProvidersPerEntry* = 20 # providers per entry
|
MaxProvidersPerEntry* = 20 # providers per entry
|
||||||
|
ValueReplication = 5 # store a value in this many nodes
|
||||||
## call
|
## call
|
||||||
|
|
||||||
func shortLog*(record: SignedPeerRecord): string =
|
func shortLog*(record: SignedPeerRecord): string =
|
||||||
@ -848,7 +849,7 @@ proc addValue*(
|
|||||||
# TODO: lookup is specified as not returning local, even if that is the closest. Is this OK?
|
# TODO: lookup is specified as not returning local, even if that is the closest. Is this OK?
|
||||||
if res.len == 0:
|
if res.len == 0:
|
||||||
res.add(d.localNode)
|
res.add(d.localNode)
|
||||||
for toNode in res:
|
for toNode in res[0 .. ValueReplication]:
|
||||||
if toNode != d.localNode:
|
if toNode != d.localNode:
|
||||||
let reqId = RequestId.init(d.rng[])
|
let reqId = RequestId.init(d.rng[])
|
||||||
d.sendRequest(toNode, AddValueMessage(cId: cId, value: value), reqId)
|
d.sendRequest(toNode, AddValueMessage(cId: cId, value: value), reqId)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user