From b8a859d5a5ab988e07bab39f324a61b0e63dd3bd Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 22 Dec 2023 17:16:50 -0600 Subject: [PATCH] add helper to derive EC block count --- tests/codex/helpers.nim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/codex/helpers.nim b/tests/codex/helpers.nim index 90b24e31..9ab8f52c 100644 --- a/tests/codex/helpers.nim +++ b/tests/codex/helpers.nim @@ -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..