From 2a7cc7725ccf2164fbb4265a4bdc77b72b1de8cb Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 11 Mar 2022 16:40:39 -0600 Subject: [PATCH] cleanup manifest --- dagger/manifest/types.nim | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 dagger/manifest/types.nim diff --git a/dagger/manifest/types.nim b/dagger/manifest/types.nim new file mode 100644 index 00000000..d1197123 --- /dev/null +++ b/dagger/manifest/types.nim @@ -0,0 +1,46 @@ +## Nim-Dagger +## Copyright (c) 2022 Status Research & Development GmbH +## Licensed under either of +## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) +## * MIT license ([LICENSE-MIT](LICENSE-MIT)) +## at your option. +## This file may not be copied, modified, or distributed except according to +## those terms. + +{.push raises: [Defect].} + +import pkg/libp2p +import pkg/questionable + +template EmptyDigests*: untyped = + var + emptyDigests {.global, threadvar.}: + array[CIDv0..CIDv1, Table[MultiCodec, MultiHash]] + + once: + emptyDigests = [ + CIDv0: { + multiCodec("sha2-256"): Cid + .init("bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku") + .get() + .mhash + .get() + }.toTable, + CIDv1: { + multiCodec("sha2-256"): Cid + .init("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n") + .get() + .mhash + .get() + }.toTable, + ] + + emptyDigests + +type + Manifest* = object of RootObj + rootHash*: ?Cid + blocks*: seq[Cid] + version*: CidVersion + hcodec*: MultiCodec + codec*: MultiCodec