mirror of
https://github.com/status-im/nim-codex.git
synced 2025-01-10 10:55:48 +00:00
05a7f47113
This is a storage engine based on IPFS, which is only a part of Dagger
23 lines
409 B
Nim
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]
|