mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-09 00:43:13 +00:00
bech codexTree
This commit is contained in:
parent
94ce22ba06
commit
d6876227d1
@ -201,6 +201,10 @@ proc benchmarkGetCidAndProof(
|
||||
discard (waitFor store.getCidAndProof(treeCid, i)).tryGet()
|
||||
i += 1
|
||||
|
||||
proc benchmarkCodexTree(cids: seq[Cid], benchmarkLoops: int) =
|
||||
benchmark "codex_tree", benchmarkLoops:
|
||||
discard CodexTree.init(cids).tryGet()
|
||||
|
||||
template profileFunc(fn: untyped) =
|
||||
enableProfiling()
|
||||
`fn`
|
||||
@ -217,11 +221,13 @@ proc benchmarkRepoStore(store: RepoStore) =
|
||||
|
||||
var
|
||||
blcks = newSeq[bt.Block]()
|
||||
cids = newSeq[Cid]()
|
||||
proofs = newSeq[CodexProof]()
|
||||
|
||||
for i in 0 ..< benchmarkLoops:
|
||||
var blk = createTestBlock(testDataLen.int)
|
||||
blcks.add(blk)
|
||||
cids.add(blk.cid)
|
||||
|
||||
let (manifest, tree) = makeManifestAndTree(blcks).tryGet()
|
||||
let treeCid = tree.rootCid.tryGet()
|
||||
@ -245,6 +251,8 @@ proc benchmarkRepoStore(store: RepoStore) =
|
||||
benchmarkPut(store, blcks, benchmarkLoops)
|
||||
benchmarkDel(store, blcks, benchmarkLoops)
|
||||
|
||||
benchmarkCodexTree(cids, benchmarkLoops)
|
||||
|
||||
proc benchStore(store: RepoStore, node: CodexNodeRef, file: File) =
|
||||
benchmark "store", 1:
|
||||
let
|
||||
|
||||
@ -15,6 +15,7 @@ import std/sequtils
|
||||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
import pkg/libp2p/[cid, multicodec, multihash]
|
||||
import pkg/constantine/hashes
|
||||
|
||||
import ../../utils
|
||||
import ../../rng
|
||||
@ -132,9 +133,13 @@ func compress*(x, y: openArray[byte], key: ByteTreeKey, mhash: MHash): ?!ByteHas
|
||||
## Compress two hashes
|
||||
##
|
||||
|
||||
var digest = newSeq[byte](mhash.size)
|
||||
mhash.coder(@x & @y & @[key.byte], digest)
|
||||
success digest
|
||||
# var digest = newSeq[byte](mhash.size)
|
||||
# #mhash.coder(@x & @y & @[key.byte], digest)
|
||||
let input = @x & @y & @[key.byte]
|
||||
|
||||
var digest = hashes.sha256.hash(input)
|
||||
|
||||
success @digest
|
||||
|
||||
func init*(
|
||||
_: type CodexTree, mcodec: MultiCodec = Sha256HashCodec, leaves: openArray[ByteHash]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user