diff --git a/codex/codextypes.nim b/codex/codextypes.nim index 57700087..87c86b51 100644 --- a/codex/codextypes.nim +++ b/codex/codextypes.nim @@ -24,6 +24,10 @@ import ./errors export tables const + # BitTorrent specific + DefaultPieceLength* = NBytes 1024 * 64 + BitTorrentBlockSize* = NBytes 1024 * 16 + # Size of blocks for storage / network exchange, DefaultBlockSize* = NBytes 1024 * 64 DefaultCellSize* = NBytes 2048 diff --git a/codex/node.nim b/codex/node.nim index a9b420bb..bd769070 100644 --- a/codex/node.nim +++ b/codex/node.nim @@ -657,7 +657,7 @@ proc storePieces*( filename: ?string = string.none, mimetype: ?string = string.none, blockSize: NBytes, - pieceLength = NBytes 1024 * 64, + pieceLength = DefaultPieceLength, ): Future[?!BitTorrentManifest] {.async.} = ## Save stream contents as dataset with given blockSize ## to nodes's BlockStore, and return Cid of its manifest @@ -708,7 +708,7 @@ proc storePieces*( return failure(&"Unable to store block {blk.cid}") pieceHashCtx.update(chunk) let idx = pieceIter.next() - trace "stored block in piece with index=", idx + trace "stored block in piece with index", idx if chunk.len < blockSize.int: trace "no more block to read" break @@ -784,7 +784,7 @@ proc storeTorrent*( without bitTorrentManifest =? await self.storePieces( - stream, filename = filename, mimetype = mimetype, blockSize = NBytes 1024 * 16 + stream, filename = filename, mimetype = mimetype, blockSize = BitTorrentBlockSize ): return failure("Unable to store BitTorrent data")