Skip to content

Commit

Permalink
Rework erasure.nim to include recent cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tbekas committed Oct 17, 2023
1 parent 85cef0e commit 78a4d79
Show file tree
Hide file tree
Showing 14 changed files with 395 additions and 269 deletions.
21 changes: 3 additions & 18 deletions codex/blockexchange/engine/engine.nim
Original file line number Diff line number Diff line change
Expand Up @@ -275,24 +275,9 @@ proc requestBlocks*(
without treeReq =? b.pendingBlocks.getOrPutTreeReq(treeCid, leavesCount.some, merkleRoot), err:
return failure(err)

var
iter = AsyncIter[Block]()
index = 0

proc next(): Future[Block] =
if index < leavesCount:
let fut = b.requestBlock(treeReq, index, timeout)
inc index
if index >= leavesCount:
iter.finished = true
return fut
else:
let fut = newFuture[Block]("engine.requestBlocks")
fut.fail(newException(CodexError, "No more elements for tree with cid " & $treeCid))
return fut

iter.next = next
return success(iter)
return Iter.fromSlice(0..<leavesCount).map(
(index: int) => b.requestBlock(treeReq, index, timeout)
).success

proc blockPresenceHandler*(
b: BlockExcEngine,
Expand Down
1 change: 1 addition & 0 deletions codex/codex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ proc new*(
repoDs = repoData,
metaDs = SQLiteDatastore.new(config.dataDir / CodexMetaNamespace)
.expect("Should create meta data store!"),
treeReader = treeReader,
quotaMaxBytes = config.storageQuota.uint,
blockTtl = config.blockTtl)

Expand Down
Loading

0 comments on commit 78a4d79

Please sign in to comment.