fix results stuff

This commit is contained in:
Jaremy Creechley 2024-05-17 01:31:53 +03:00
parent 96862372e5
commit ebc284ae6a
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 22 additions and 9 deletions

View File

@ -56,8 +56,20 @@ proc prove*[H](
let args = ProveTaskArgs(signal: signal, params: self.params) let args = ProveTaskArgs(signal: signal, params: self.params)
let flowvar = self.tp.spawn proveTask(args, input) let flowvar = self.tp.spawn proveTask(args, input)
without res =? await awaitThreadResult(signal, flowvar), err: without taskRes =? await awaitThreadResult(signal, flowvar), err:
return failure(err) let res: ?!CircomProof = failure(err)
return res
without proof =? taskRes.mapFailure, err:
let res: ?!CircomProof = failure(err)
return res
let sigRes = signal.close()
if sigRes.isErr:
return failure(sigRes.error())
let pf: CircomProof = proof
success(pf)
proc verify*[H]( proc verify*[H](
self: AsyncCircomCompat, proof: CircomProof, inputs: ProofInputs[H] self: AsyncCircomCompat, proof: CircomProof, inputs: ProofInputs[H]

View File

@ -15,11 +15,12 @@ proc awaitThreadResult*[T](signal: ThreadSignalPtr, handle: Flowvar[T]): Future[
var var
res: T res: T
awaitTotal: Duration awaitTotal: Duration
while awaitTotal < CompletionTimeout:
if handle.tryComplete(res):
return success(res)
else:
awaitTotal += CompletionRetryDelay
await sleepAsync(CompletionRetryDelay)
return failure("Task signaled finish but didn't return any result within " & $CompletionRetryDelay) while awaitTotal < CompletionTimeout:
if handle.tryComplete(res):
return success(res)
else:
awaitTotal += CompletionRetryDelay
await sleepAsync(CompletionRetryDelay)
return failure("Task signaled finish but didn't return any result within " & $CompletionRetryDelay)