Skip to content

Commit f6a0e9d

Browse files
committed
review: makes handing ValueError in getPendingBlocks cleaner
1 parent 4383211 commit f6a0e9d

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

codex/erasure/erasure.nim

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ proc getPendingBlocks(
125125
## Get pending blocks iterator
126126
##
127127

128-
if indices.len == 0:
129-
trace "No indices to fetch blocks for", treeCid = manifest.treeCid
130-
return AsyncResultIter[(?!bt.Block, int)].empty()
131-
132128
var pendingBlocks: seq[Future[(?!bt.Block, int)].Raising([CancelledError])] = @[]
133129

134130
proc attachIndex(
@@ -158,10 +154,8 @@ proc getPendingBlocks(
158154
$index
159155
)
160156
except ValueError as err:
161-
# ValueError is raised by `one` when the pendingBlocks is empty -
162-
# but we check for that at the very beginning -
163-
# thus, if this happens, we raise an assert
164-
raiseAssert("fatal: pendingBlocks is empty - this should never happen")
157+
# ValueError is raised by `one` when the pendingBlocks is empty
158+
return failure("iterator finished (pendingBlocks empty) but genNext() was called")
165159

166160
AsyncResultIter[(?!bt.Block, int)].new(genNext, isFinished)
167161

0 commit comments

Comments
 (0)