resolves build issue, onboards allfuturesthrowing with warning

This commit is contained in:
Ben 2024-08-15 15:00:08 +02:00
parent 38302936b9
commit b742d95d28
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
3 changed files with 29 additions and 4 deletions

View File

@ -44,6 +44,7 @@ import ./utils/addrutils
import ./namespaces
import ./codextypes
import ./logutils
import ./utils
logScope:
topics = "codex node"

View File

@ -246,8 +246,8 @@ proc buildSlot*[T, H](
if err =? (await self.store.putCidAndProof(
treeCid, i, cellCid, encodableProof)).errorOption:
error "Failed to store slot tree", error = error.msg
return failure(error)
error "Failed to store slot tree", error = err.msg
return failure(err)
tree.root()
@ -286,8 +286,8 @@ proc buildSlots*[T, H](self: SlotsBuilder[T, H]): Future[?!void] {.async.} =
proc buildManifest*[T, H](self: SlotsBuilder[T, H]): Future[?!Manifest] {.async.} =
if err =? (await self.buildSlots()).errorOption:
error "Failed to build slot roots", error = error.msg
return failure(error)
error "Failed to build slot roots", error = err.msg
return failure(err)
without rootCids =? self.slotRoots.toSlotCids(), error:
error "Failed to map slot roots to CIDs", error = error.msg

View File

@ -54,6 +54,30 @@ template findIt*(s, pred: untyped): untyped =
break
index
proc allFuturesThrowing*[T](args: varargs[Future[T]]): Future[void] =
# TODO: Copied from previous libp2p
# Comes with warnings: Can this hide errors?
var futs: seq[Future[T]]
for fut in args:
futs &= fut
proc call() {.async.} =
var first: ref CatchableError = nil
futs = await allFinished(futs)
for fut in futs:
if fut.failed:
let err = fut.readError()
if err of Defect:
raise err
else:
if err of CancelledError:
raise err
if isNil(first):
first = err
if not isNil(first):
raise first
return call()
when not declared(parseDuration): # Odd code formatting to minimize diff v. mainLine
const Whitespace = {' ', '\t', '\v', '\r', '\l', '\f'}