From f6a0e9dcf870e34380a24b82c56a592ae19a7e0f Mon Sep 17 00:00:00 2001 From: Marcin Czenko Date: Wed, 25 Jun 2025 19:10:52 +0200 Subject: [PATCH] review: makes handing ValueError in getPendingBlocks cleaner --- codex/erasure/erasure.nim | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/codex/erasure/erasure.nim b/codex/erasure/erasure.nim index a875847c..d678e70d 100644 --- a/codex/erasure/erasure.nim +++ b/codex/erasure/erasure.nim @@ -125,10 +125,6 @@ proc getPendingBlocks( ## Get pending blocks iterator ## - if indices.len == 0: - trace "No indices to fetch blocks for", treeCid = manifest.treeCid - return AsyncResultIter[(?!bt.Block, int)].empty() - var pendingBlocks: seq[Future[(?!bt.Block, int)].Raising([CancelledError])] = @[] proc attachIndex( @@ -158,10 +154,8 @@ proc getPendingBlocks( $index ) except ValueError as err: - # ValueError is raised by `one` when the pendingBlocks is empty - - # but we check for that at the very beginning - - # thus, if this happens, we raise an assert - raiseAssert("fatal: pendingBlocks is empty - this should never happen") + # ValueError is raised by `one` when the pendingBlocks is empty + return failure("iterator finished (pendingBlocks empty) but genNext() was called") AsyncResultIter[(?!bt.Block, int)].new(genNext, isFinished)