fixes checking block results

This commit is contained in:
Marcin Czenko 2025-03-24 02:14:09 +01:00
parent 42b74cc11f
commit 774f6d2841
No known key found for this signature in database
GPG Key ID: 33DEA0C8E30937C0

View File

@ -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)