mirror of
https://github.com/logos-storage/das-dht-emulator.git
synced 2026-01-04 06:03:08 +00:00
startSamplingDA: expose sample IDs
expose sample IDs and log if individual getValue fails. Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
6df79c44e6
commit
9f7376ebef
9
das.nim
9
das.nim
@ -149,7 +149,7 @@ when isMainModule:
|
|||||||
await sleepAsync(sampling_delay)
|
await sleepAsync(sampling_delay)
|
||||||
|
|
||||||
# sample
|
# sample
|
||||||
proc startSamplingDA(n: discv5_protocol.Protocol): seq[Future[DiscResult[seq[byte]]]] =
|
proc startSamplingDA(n: discv5_protocol.Protocol): (seq[int], seq[Future[DiscResult[seq[byte]]]]) =
|
||||||
## Generate random sample and start the sampling process
|
## Generate random sample and start the sampling process
|
||||||
var futs = newSeq[Future[DiscResult[seq[byte]]]]()
|
var futs = newSeq[Future[DiscResult[seq[byte]]]]()
|
||||||
|
|
||||||
@ -158,12 +158,12 @@ when isMainModule:
|
|||||||
for s in sample:
|
for s in sample:
|
||||||
let fut = n.getValue(segmentIDs[s])
|
let fut = n.getValue(segmentIDs[s])
|
||||||
futs.add(fut)
|
futs.add(fut)
|
||||||
return futs
|
return (sample, futs)
|
||||||
|
|
||||||
proc sampleDA(n: discv5_protocol.Protocol): Future[(bool, int, Duration)] {.async.} =
|
proc sampleDA(n: discv5_protocol.Protocol): Future[(bool, int, Duration)] {.async.} =
|
||||||
## Sample and return detailed results of sampling
|
## Sample and return detailed results of sampling
|
||||||
let startTime = Moment.now()
|
let startTime = Moment.now()
|
||||||
var futs = startSamplingDA(n)
|
var (sample, futs) = startSamplingDA(n)
|
||||||
|
|
||||||
# test is passed if all segments are retrieved in time
|
# test is passed if all segments are retrieved in time
|
||||||
discard await allFutures(futs).withTimeout(sampling_timeout)
|
discard await allFutures(futs).withTimeout(sampling_timeout)
|
||||||
@ -171,6 +171,9 @@ when isMainModule:
|
|||||||
for i in 0 ..< futs.len:
|
for i in 0 ..< futs.len:
|
||||||
if futs[i].finished() and isOk(await futs[i]):
|
if futs[i].finished() and isOk(await futs[i]):
|
||||||
passcount += 1
|
passcount += 1
|
||||||
|
else:
|
||||||
|
info "sample failed", by = n.localNode, s = sample[i], key = segmentIDs[sample[i]]
|
||||||
|
|
||||||
|
|
||||||
let
|
let
|
||||||
time = Moment.now() - startTime
|
time = Moment.now() - startTime
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user