## Nim-Codex ## Copyright (c) 2021 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. import pkg/upraises push: {.upraises: [].} import pkg/chronos import pkg/libp2p import pkg/questionable import pkg/questionable/results import ../clock import ../blocktype import ../merkletree import ../utils export blocktype type BlockNotFoundError* = object of CodexError BlockType* {.pure.} = enum Manifest, Block, Both BlockStore* = ref object of RootObj method getBlock*(self: BlockStore, cid: Cid): Future[?!Block] {.base.} = ## Get a block from the blockstore ## raiseAssert("getBlock by cid not implemented!") method getBlock*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!Block] {.base.} = ## Get a block from the blockstore ## raiseAssert("getBlock by treecid not implemented!") method getBlock*(self: BlockStore, address: BlockAddress): Future[?!Block] {.base.} = ## Get a block from the blockstore ## raiseAssert("getBlock by addr not implemented!") method getBlockAndProof*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!(Block, MerkleProof)] {.base.} = ## Get a block and associated inclusion proof by Cid of a merkle tree and an index of a leaf in a tree ## raiseAssert("getBlockAndProof not implemented!") method getTree*(self: BlockStore, treeCid: Cid): Future[?!MerkleTree] {.base.} = ## Get a merkle tree by Cid ## raiseAssert("Not implemented!") method getBlock*(self: BlockStore, treeCid: Cid, index: Natural, merkleRoot: MultiHash): Future[?!Block] {.base.} = ## Get a block by Cid of a merkle tree and an index of a leaf in a tree, validate inclusion using merkle root ## raiseAssert("Not implemented!") method getBlockAndProof*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!(Block, MerkleProof)] {.base.} = ## Get a block and associated inclusion proof by Cid of a merkle tree and an index of a leaf in a tree ## raiseAssert("Not implemented!") method getBlocks*(self: BlockStore, treeCid: Cid, leavesCount: Natural, merkleRoot: MultiHash): Future[?!AsyncIter[?!Block]] {.base.} = ## Get all blocks in range [0..