From 774f6d284102d824047df925530193a4ce5a8f58 Mon Sep 17 00:00:00 2001 From: Marcin Czenko Date: Mon, 24 Mar 2025 02:14:09 +0100 Subject: [PATCH] fixes checking block results --- codex/node.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/codex/node.nim b/codex/node.nim index b64baf96..164d6ca0 100644 --- a/codex/node.nim +++ b/codex/node.nim @@ -436,10 +436,14 @@ proc fetchPieces*( let address = BlockAddress.init(cid, blockIter.next()) self.networkStore.getBlock(address) - without blocks =? await allFinishedValues(blockFutures), err: + without blockResults =? await allFinishedValues(blockFutures), err: return failure(err) - if err =? self.validatePiece(pieceValidator, blocks).errorOption: + let numOfFailedBlocks = blockResults.countIt(it.isFailure) + if numOfFailedBlocks > 0: + return failure("Some blocks failed to fetch") + + if err =? self.validatePiece(pieceValidator, blockResults.mapIt(it.get)).errorOption: return failure(err) await sleepAsync(1.millis)