mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-09 17:03:09 +00:00
review: makes handing ValueError in getPendingBlocks cleaner
This commit is contained in:
parent
4383211b8d
commit
f6a0e9dcf8
@ -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)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user