parent
06bb21bfc7
commit
8d61391073
|
@ -30,17 +30,17 @@ export types
|
||||||
|
|
||||||
type
|
type
|
||||||
Manifest* = ref object of RootObj
|
Manifest* = ref object of RootObj
|
||||||
treeCid {.serialize.}: Cid # Root of the merkle tree
|
treeCid {.serialize.}: Cid # Root of the merkle tree
|
||||||
datasetSize {.serialize.}: NBytes # Total size of all blocks
|
datasetSize {.serialize.}: NBytes # Total size of all blocks
|
||||||
blockSize {.serialize.}: NBytes # Size of each contained block (might not be needed if blocks are len-prefixed)
|
blockSize {.serialize.}: NBytes # Size of each contained block (might not be needed if blocks are len-prefixed)
|
||||||
version: CidVersion # Cid version
|
version: CidVersion # Cid version
|
||||||
hcodec: MultiCodec # Multihash codec
|
hcodec: MultiCodec # Multihash codec
|
||||||
codec: MultiCodec # Data set codec
|
codec: MultiCodec # Data set codec
|
||||||
case protected {.serialize.}: bool # Protected datasets have erasure coded info
|
case protected {.serialize.}: bool # Protected datasets have erasure coded info
|
||||||
of true:
|
of true:
|
||||||
ecK: int # Number of blocks to encode
|
ecK: int # Number of blocks to encode
|
||||||
ecM: int # Number of resulting parity blocks
|
ecM: int # Number of resulting parity blocks
|
||||||
originalTreeCid: Cid # The original root of the dataset being erasure coded
|
originalTreeCid: Cid # The original root of the dataset being erasure coded
|
||||||
originalDatasetSize: NBytes
|
originalDatasetSize: NBytes
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
|
@ -96,7 +96,6 @@ proc encode(cidAndProof: (Cid, MerkleProof)): seq[byte] =
|
||||||
proc decode(_: type (Cid, MerkleProof), data: seq[byte]): ?!(Cid, MerkleProof) =
|
proc decode(_: type (Cid, MerkleProof), data: seq[byte]): ?!(Cid, MerkleProof) =
|
||||||
let
|
let
|
||||||
n = uint64.fromBytesBE(data[0..<sizeof(uint64)]).int
|
n = uint64.fromBytesBE(data[0..<sizeof(uint64)]).int
|
||||||
let
|
|
||||||
cid = ? Cid.init(data[sizeof(uint64)..<sizeof(uint64) + n]).mapFailure
|
cid = ? Cid.init(data[sizeof(uint64)..<sizeof(uint64) + n]).mapFailure
|
||||||
proof = ? MerkleProof.decode(data[sizeof(uint64) + n..^1])
|
proof = ? MerkleProof.decode(data[sizeof(uint64) + n..^1])
|
||||||
success((cid, proof))
|
success((cid, proof))
|
||||||
|
|
Loading…
Reference in New Issue