From bcecd0c3340a22cb4b55c3c07ba8301ed85c9bcc Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 19 Jun 2023 12:11:59 +0200 Subject: [PATCH] add ValueReplication cound for addValue Signed-off-by: Csaba Kiraly --- libp2pdht/private/eth/p2p/discoveryv5/protocol.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libp2pdht/private/eth/p2p/discoveryv5/protocol.nim b/libp2pdht/private/eth/p2p/discoveryv5/protocol.nim index 8a79651..aa0d437 100644 --- a/libp2pdht/private/eth/p2p/discoveryv5/protocol.nim +++ b/libp2pdht/private/eth/p2p/discoveryv5/protocol.nim @@ -129,6 +129,7 @@ const ResponseTimeout* = 4.seconds ## timeout for the response of a request-response MaxProvidersEntries* = 1_000_000 # one million records MaxProvidersPerEntry* = 20 # providers per entry + ValueReplication = 5 # store a value in this many nodes ## call func shortLog*(record: SignedPeerRecord): string = @@ -860,7 +861,7 @@ 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: + for toNode in res[0 .. ValueReplication]: if toNode != d.localNode: let reqId = RequestId.init(d.rng[]) d.sendRequest(toNode, AddValueMessage(cId: cId, value: value), reqId)