Skip to content

Commit

Permalink
Node.store: added blockSize parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Bulat-Ziganshin committed Aug 24, 2022
1 parent 21771aa commit d95cdb8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions codex/node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ proc fetchBatched*(
proc retrieve*(
node: CodexNodeRef,
cid: Cid): Future[?!LPStream] {.async.} =
## Retrieve a block or manifest
## Retrieve by Cid a single block or an entire dataset described by manifest
##

if manifest =? (await node.fetchManifest(cid)):
Expand Down Expand Up @@ -163,14 +163,18 @@ proc retrieve*(

proc store*(
node: CodexNodeRef,
stream: LPStream): Future[?!Cid] {.async.} =
stream: LPStream,
blockSize = BlockSize): Future[?!Cid] {.async.} =
## Save stream contents as dataset with given blockSize
## to nodes's BlockStore, and return Cid of its manifest
##
trace "Storing data"

without var blockManifest =? Manifest.new(blockSize = BlockSize):
without var blockManifest =? Manifest.new(blockSize = blockSize):
return failure("Unable to create Block Set")

# Manifest and chunker should have the same chunk size
let chunker = LPStreamChunker.new(stream, chunkSize = BlockSize)
# Manifest and chunker should use the same blockSize
let chunker = LPStreamChunker.new(stream, chunkSize = blockSize)

try:
while (
Expand Down

0 comments on commit d95cdb8

Please sign in to comment.