mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-03 22:13:12 +00:00
22 lines
439 B
Nim
22 lines
439 B
Nim
import std/tables
|
|
import std/hashes
|
|
import ./merkledag
|
|
|
|
export merkledag
|
|
|
|
type
|
|
Repo* = ref object
|
|
storage: Table[MultiHash, MerkleDag]
|
|
|
|
proc hash(multihash: MultiHash): Hash =
|
|
hash($multihash)
|
|
|
|
proc store*(repo: Repo, dag: MerkleDag) =
|
|
repo.storage[dag.rootHash] = dag
|
|
|
|
proc contains*(repo: Repo, hash: MultiHash): bool =
|
|
repo.storage.hasKey(hash)
|
|
|
|
proc retrieve*(repo: Repo, hash: MultiHash): MerkleDag =
|
|
repo.storage[hash]
|