nim-dagger/ipfs/ipfsobject.nim

11 lines
234 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
IpfsObject* = object
data*: seq[byte]
2021-01-12 12:43:23 +00:00
proc cid*(obj: IpfsObject): Cid =
2021-01-14 12:41:54 +00:00
let codec = multiCodec("dag-pb")
let hash = MultiHash.digest("sha2-256", obj.data).get()
2021-01-14 12:41:54 +00:00
Cid.init(CIDv0, codec, hash).get()