From 9f7376ebefc4f97a20925bb1fd46797f31e29cbb Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 5 Sep 2023 09:47:34 +0200 Subject: [PATCH] startSamplingDA: expose sample IDs expose sample IDs and log if individual getValue fails. Signed-off-by: Csaba Kiraly --- das.nim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/das.nim b/das.nim index 48e9263..2084aae 100644 --- a/das.nim +++ b/das.nim @@ -149,7 +149,7 @@ when isMainModule: await sleepAsync(sampling_delay) # 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 var futs = newSeq[Future[DiscResult[seq[byte]]]]() @@ -158,12 +158,12 @@ when isMainModule: for s in sample: let fut = n.getValue(segmentIDs[s]) futs.add(fut) - return futs + return (sample, futs) proc sampleDA(n: discv5_protocol.Protocol): Future[(bool, int, Duration)] {.async.} = ## Sample and return detailed results of sampling let startTime = Moment.now() - var futs = startSamplingDA(n) + var (sample, futs) = startSamplingDA(n) # test is passed if all segments are retrieved in time discard await allFutures(futs).withTimeout(sampling_timeout) @@ -171,6 +171,9 @@ when isMainModule: for i in 0 ..< futs.len: if futs[i].finished() and isOk(await futs[i]): passcount += 1 + else: + info "sample failed", by = n.localNode, s = sample[i], key = segmentIDs[sample[i]] + let time = Moment.now() - startTime