Kagome
Polkadot Runtime Engine in C++17
|
#include <block_tree.hpp>
Public Types | |
enum | GetChainDirection { GetChainDirection::ASCEND, GetChainDirection::DESCEND } |
using | BlockHashVecRes = outcome::result< std::vector< primitives::BlockHash >> |
Public Member Functions | |
virtual | ~BlockTree ()=default |
virtual const primitives::BlockHash & | getGenesisBlockHash () const =0 |
virtual outcome::result< bool > | hasBlockHeader (const primitives::BlockId &block) const =0 |
virtual outcome::result< primitives::BlockHeader > | getBlockHeader (const primitives::BlockId &block) const =0 |
virtual outcome::result< primitives::BlockBody > | getBlockBody (const primitives::BlockId &block) const =0 |
virtual outcome::result< primitives::Justification > | getBlockJustification (const primitives::BlockId &block) const =0 |
virtual outcome::result< void > | addBlockHeader (const primitives::BlockHeader &header)=0 |
virtual outcome::result< void > | addBlockBody (primitives::BlockNumber block_number, const primitives::BlockHash &block_hash, const primitives::BlockBody &block_body)=0 |
virtual outcome::result< void > | addExistingBlock (const primitives::BlockHash &block_hash, const primitives::BlockHeader &block_header)=0 |
virtual outcome::result< void > | addBlock (const primitives::Block &block)=0 |
virtual outcome::result< void > | removeLeaf (const primitives::BlockHash &block_hash)=0 |
virtual outcome::result< void > | finalize (const primitives::BlockHash &block, const primitives::Justification &justification)=0 |
virtual BlockHashVecRes | getBestChainFromBlock (const primitives::BlockHash &block, uint64_t maximum) const =0 |
virtual BlockHashVecRes | getDescendingChainToBlock (const primitives::BlockHash &block, uint64_t maximum) const =0 |
virtual BlockHashVecRes | getChainByBlocks (const primitives::BlockHash &ancestor, const primitives::BlockHash &descendant) const =0 |
virtual bool | hasDirectChain (const primitives::BlockHash &ancestor, const primitives::BlockHash &descendant) const =0 |
virtual primitives::BlockInfo | deepestLeaf () const =0 |
virtual outcome::result< primitives::BlockInfo > | getBestContaining (const primitives::BlockHash &target_hash, const std::optional< primitives::BlockNumber > &max_number) const =0 |
Get the most recent block of the best (longest) chain among those that contain a block with. More... | |
virtual std::vector< primitives::BlockHash > | getLeaves () const =0 |
virtual BlockHashVecRes | getChildren (const primitives::BlockHash &block) const =0 |
virtual primitives::BlockInfo | getLastFinalized () const =0 |
Storage for blocks, which has a form of tree; it serves two functions:
Definition at line 30 of file block_tree.hpp.
using kagome::blockchain::BlockTree::BlockHashVecRes = outcome::result<std::vector<primitives::BlockHash>> |
Definition at line 32 of file block_tree.hpp.
|
strong |
Enumerator | |
---|---|
ASCEND | |
DESCEND |
Definition at line 140 of file block_tree.hpp.
|
virtualdefault |
|
pure virtual |
Add a new block to the tree
block | to be stored and added to tree |
block) | is not in our local storage, corresponding error is returned. It is suggested that after getting that error, the caller would ask another peer for the parent block and try to insert it; this operation is to be repeated until a successful insertion happens |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Adds block body to the storage
block_number | that corresponds to the block which body we are adding |
block_hash | that corresponds to the block which body we are adding |
block_body | that we are adding |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Adds header to the storage
header | that we are adding |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Add an existent block to the tree
block_hash | is hash of the added block in the tree |
block_header | is header of that block |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get a deepest leaf of the tree
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Mark the block as finalized and store a finalization justification
block | to be finalized |
justification | of the finalization |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get a chain of blocks from provided block to best block direction
block,from | which the chain is started |
maximum | number of blocks to be retrieved |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get the most recent block of the best (longest) chain among those that contain a block with.
target_hash | |
target_hash | is a hash of a block that the chosen chain must contain |
max_number | is the max block number that the resulting block (and the target one) may possess |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get a body (extrinsics) of the block (if present)
block | - id of the block to get body for |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get block header by provided block id
block | id of the block header we are looking for |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get a justification of the block (if present)
block | - id of the block to get justification for |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get a chain of blocks. Implies hasDirectChain(ancestor, descendant)
.
ancestor | - block, which is closest to the genesis |
descendant | - block, which is farthest from the genesis |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get children of the block with specified hash
block | to get children of |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get a chain of blocks before provided block including its
block,to | which the chain is ended |
maximum | number of blocks to be retrieved |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get the last finalized block
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Get all leaves of our tree
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Checks containing of block header by provided block id
block | id of the block header we are checking |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Check if one block is ancestor of second one (direct chain exists)
ancestor | - block, which is closest to the genesis |
descendant | - block, which is farthest from the genesis |
ancestor | is ancestor of |
descendant |
Implemented in kagome::blockchain::BlockTreeImpl.
|
pure virtual |
Remove leaf
block_hash | - hash of block to be deleted. The block must be leaf. |
Implemented in kagome::blockchain::BlockTreeImpl.