Kagome
Polkadot Runtime Engine in C++17
block_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_BLOCK_STORAGE_HPP
7 #define KAGOME_BLOCK_STORAGE_HPP
8 
9 #include "primitives/block.hpp"
11 #include "primitives/block_id.hpp"
13 
14 namespace kagome::blockchain {
15 
20  class BlockStorage {
21  public:
22  virtual ~BlockStorage() = default;
23 
28  virtual outcome::result<std::vector<primitives::BlockHash>>
29  getBlockTreeLeaves() const = 0;
30 
35  virtual outcome::result<void> setBlockTreeLeaves(
36  std::vector<primitives::BlockHash> leaves) = 0;
37 
39  virtual outcome::result<bool> hasBlockHeader(
40  const primitives::BlockId &id) const = 0;
41 
46  virtual outcome::result<std::optional<primitives::BlockHeader>>
47  getBlockHeader(const primitives::BlockId &id) const = 0;
48 
53  virtual outcome::result<std::optional<primitives::BlockBody>> getBlockBody(
54  const primitives::BlockId &id) const = 0;
55 
60  virtual outcome::result<std::optional<primitives::BlockData>> getBlockData(
61  const primitives::BlockId &id) const = 0;
62 
67  virtual outcome::result<std::optional<primitives::Justification>>
68  getJustification(const primitives::BlockId &block) const = 0;
69 
74  virtual outcome::result<void> putNumberToIndexKey(
75  const primitives::BlockInfo &block) = 0;
76 
81  virtual outcome::result<primitives::BlockHash> putBlockHeader(
82  const primitives::BlockHeader &header) = 0;
83 
88  virtual outcome::result<void> putBlockData(
89  primitives::BlockNumber, const primitives::BlockData &block_data) = 0;
90 
97  virtual outcome::result<void> removeBlockData(
98  primitives::BlockNumber block_number,
99  const primitives::BlockDataFlags &remove_flags) = 0;
104  virtual outcome::result<primitives::BlockHash> putBlock(
105  const primitives::Block &block) = 0;
106 
112  virtual outcome::result<void> putJustification(
113  const primitives::Justification &justification,
114  const primitives::BlockHash &hash,
115  primitives::BlockNumber number) = 0;
116 
122  virtual outcome::result<void> removeJustification(
123  const primitives::BlockHash &hash, primitives::BlockNumber number) = 0;
124 
129  virtual outcome::result<primitives::BlockInfo> getLastFinalized() const = 0;
130 
135  virtual outcome::result<void> removeBlock(
136  const primitives::BlockInfo &block) = 0;
137  };
138 
139 } // namespace kagome::blockchain
140 
141 #endif // KAGOME_BLOCK_STORAGE_HPP
virtual outcome::result< void > removeBlockData(primitives::BlockNumber block_number, const primitives::BlockDataFlags &remove_flags)=0
virtual outcome::result< std::optional< primitives::BlockBody > > getBlockBody(const primitives::BlockId &id) const =0
virtual outcome::result< void > setBlockTreeLeaves(std::vector< primitives::BlockHash > leaves)=0
virtual outcome::result< void > removeBlock(const primitives::BlockInfo &block)=0
Block class represents polkadot block primitive.
Definition: block.hpp:19
virtual outcome::result< void > putJustification(const primitives::Justification &justification, const primitives::BlockHash &hash, primitives::BlockNumber number)=0
virtual outcome::result< void > removeJustification(const primitives::BlockHash &hash, primitives::BlockNumber number)=0
virtual outcome::result< std::optional< primitives::Justification > > getJustification(const primitives::BlockId &block) const =0
virtual outcome::result< std::vector< primitives::BlockHash > > getBlockTreeLeaves() const =0
virtual outcome::result< std::optional< primitives::BlockData > > getBlockData(const primitives::BlockId &id) const =0
uint32_t BlockNumber
Definition: common.hpp:18
virtual outcome::result< void > putNumberToIndexKey(const primitives::BlockInfo &block)=0
virtual outcome::result< primitives::BlockInfo > getLastFinalized() const =0
virtual outcome::result< bool > hasBlockHeader(const primitives::BlockId &id) const =0
Check if header existing by provided block {.
virtual outcome::result< primitives::BlockHash > putBlock(const primitives::Block &block)=0
virtual outcome::result< primitives::BlockHash > putBlockHeader(const primitives::BlockHeader &header)=0
virtual outcome::result< void > putBlockData(primitives::BlockNumber, const primitives::BlockData &block_data)=0
virtual outcome::result< std::optional< primitives::BlockHeader > > getBlockHeader(const primitives::BlockId &id) const =0
boost::variant< BlockHash, BlockNumber > BlockId
Block id is the variant over BlockHash and BlockNumber.
Definition: block_id.hpp:18