nim-codex/ipfs/repo.nim
Mark Spanbroek 05a7f47113 Rename dagger->ipfs
This is a storage engine based on IPFS, which is only a part of Dagger
2021-02-02 19:29:52 +01:00

23 lines
409 B
Nim

import std/tables
import std/hashes
import pkg/libp2p
import ./merkledag
export merkledag
type
Repo* = ref object
storage: Table[Cid, MerkleDag]
proc hash(id: Cid): Hash =
hash($id)
proc store*(repo: Repo, dag: MerkleDag) =
repo.storage[dag.rootId] = dag
proc contains*(repo: Repo, id: Cid): bool =
repo.storage.hasKey(id)
proc retrieve*(repo: Repo, id: Cid): MerkleDag =
repo.storage[id]