nim-codex/ipfs/merkledag.nim

11 lines
235 B
Nim
Raw Normal View History

2021-01-14 12:41:54 +00:00
import pkg/libp2p
2021-01-12 12:43:23 +00:00
type
MerkleDag* = object
data*: seq[byte]
2021-01-12 12:43:23 +00:00
2021-01-14 12:41:54 +00:00
proc rootId*(dag: MerkleDag): Cid =
let codec = multiCodec("dag-pb")
let hash = MultiHash.digest("sha2-256", dag.data).get()
Cid.init(CIDv0, codec, hash).get()