mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-17 12:53:07 +00:00
add helper to derive EC block count
This commit is contained in:
parent
f15f3f5f27
commit
b8a859d5a5
@ -9,6 +9,7 @@ import pkg/codex/manifest
|
||||
import pkg/codex/merkletree
|
||||
import pkg/codex/blockexchange
|
||||
import pkg/codex/rng
|
||||
import pkg/codex/utils
|
||||
|
||||
import ./helpers/nodeutils
|
||||
import ./helpers/randomchunker
|
||||
@ -27,6 +28,13 @@ export libp2p except setup, eventually
|
||||
func `==`*(a, b: Block): bool =
|
||||
(a.cid == b.cid) and (a.data == b.data)
|
||||
|
||||
proc calcEcBlocksCount*(blocksCount: int, ecK, ecM: int): int =
|
||||
let
|
||||
rounded = roundUp(blocksCount, ecK)
|
||||
steps = divUp(blocksCount, ecK)
|
||||
|
||||
rounded + (steps * ecM)
|
||||
|
||||
proc lenPrefix*(msg: openArray[byte]): seq[byte] =
|
||||
## Write `msg` with a varint-encoded length prefix
|
||||
##
|
||||
@ -94,7 +102,7 @@ proc storeDataGetManifest*(store: BlockStore, chunker: Chunker): Future[Manifest
|
||||
|
||||
for i in 0..<tree.leavesCount:
|
||||
let proof = tree.getProof(i).tryGet()
|
||||
(await store.putBlockCidAndProof(treeCid, i, cids[i], proof)).tryGet()
|
||||
(await store.putCidAndProof(treeCid, i, cids[i], proof)).tryGet()
|
||||
|
||||
return manifest
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user