mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-13 02:43:07 +00:00
adds BitTorrent specific constants
This commit is contained in:
parent
096dff0714
commit
f0a9306320
@ -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
|
||||
|
||||
@ -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")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user