mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-02-11 09:03:12 +00:00
add digest for multihash
This commit is contained in:
parent
7579409c7d
commit
257385e6f4
@ -10,6 +10,7 @@
|
||||
import pkg/poseidon2
|
||||
import pkg/poseidon2/io
|
||||
import pkg/questionable/results
|
||||
import pkg/libp2p/multihash
|
||||
|
||||
import ../merkletree
|
||||
|
||||
@ -38,3 +39,15 @@ func digest*(
|
||||
##
|
||||
|
||||
(? Poseidon2Tree.digestTree(bytes, chunkSize)).root
|
||||
|
||||
func digestMhash*(
|
||||
_: type Poseidon2Tree,
|
||||
bytes: openArray[byte], chunkSize: int): ?!MultiHash =
|
||||
## Hashes chunks of data with a sponge of rate 2 and
|
||||
## returns the multihash of the root
|
||||
##
|
||||
|
||||
let
|
||||
hash = ? Poseidon2Tree.digest(bytes, chunkSize)
|
||||
|
||||
? MultiHash.init(Pos2Bn128MrklCodec, hash).mapFailure
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user