Kagome
Polkadot Runtime Engine in C++17
kagome::blockchain::BlockStorage Class Referenceabstract

#include <block_storage.hpp>

Inheritance diagram for kagome::blockchain::BlockStorage:
Collaboration diagram for kagome::blockchain::BlockStorage:

Public Member Functions

virtual ~BlockStorage ()=default
 
virtual outcome::result< std::vector< primitives::BlockHash > > getBlockTreeLeaves () const =0
 
virtual outcome::result< void > setBlockTreeLeaves (std::vector< primitives::BlockHash > leaves)=0
 
virtual outcome::result< bool > hasBlockHeader (const primitives::BlockId &id) const =0
 Check if header existing by provided block {. More...
 
virtual outcome::result< std::optional< primitives::BlockHeader > > getBlockHeader (const primitives::BlockId &id) const =0
 
virtual outcome::result< std::optional< primitives::BlockBody > > getBlockBody (const primitives::BlockId &id) const =0
 
virtual outcome::result< std::optional< primitives::BlockData > > getBlockData (const primitives::BlockId &id) const =0
 
virtual outcome::result< std::optional< primitives::Justification > > getJustification (const primitives::BlockId &block) const =0
 
virtual outcome::result< void > putNumberToIndexKey (const primitives::BlockInfo &block)=0
 
virtual outcome::result< primitives::BlockHashputBlockHeader (const primitives::BlockHeader &header)=0
 
virtual outcome::result< void > putBlockData (primitives::BlockNumber, const primitives::BlockData &block_data)=0
 
virtual outcome::result< void > removeBlockData (primitives::BlockNumber block_number, const primitives::BlockDataFlags &remove_flags)=0
 
virtual outcome::result< primitives::BlockHashputBlock (const primitives::Block &block)=0
 
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< primitives::BlockInfogetLastFinalized () const =0
 
virtual outcome::result< void > removeBlock (const primitives::BlockInfo &block)=0
 

Detailed Description

A wrapper for a storage of blocks Provides a convenient interface to work with it

Definition at line 20 of file block_storage.hpp.

Constructor & Destructor Documentation

virtual kagome::blockchain::BlockStorage::~BlockStorage ( )
virtualdefault

Member Function Documentation

virtual outcome::result<std::optional<primitives::BlockBody> > kagome::blockchain::BlockStorage::getBlockBody ( const primitives::BlockId id) const
pure virtual

Tries to get block body by {

Parameters
id}
Returns
block body or error

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<std::optional<primitives::BlockData> > kagome::blockchain::BlockStorage::getBlockData ( const primitives::BlockId id) const
pure virtual

Tries to get block data by {

Parameters
id}
Returns
block data or error

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<std::optional<primitives::BlockHeader> > kagome::blockchain::BlockStorage::getBlockHeader ( const primitives::BlockId id) const
pure virtual

Tries to get block header by {

Parameters
id}
Returns
block header or error

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<std::vector<primitives::BlockHash> > kagome::blockchain::BlockStorage::getBlockTreeLeaves ( ) const
pure virtual

Obtains leaves of block tree

Returns
hashes of block tree leaves

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<std::optional<primitives::Justification> > kagome::blockchain::BlockStorage::getJustification ( const primitives::BlockId block) const
pure virtual

Tries to get justification of block finality by {

Parameters
id}
Returns
justification or error

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<primitives::BlockInfo> kagome::blockchain::BlockStorage::getLastFinalized ( ) const
pure virtual

Get the last finalized block

Returns
BlockInfo of the block

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<bool> kagome::blockchain::BlockStorage::hasBlockHeader ( const primitives::BlockId id) const
pure virtual

Check if header existing by provided block {.

Parameters
id}

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<primitives::BlockHash> kagome::blockchain::BlockStorage::putBlock ( const primitives::Block block)
pure virtual

Saves {

Parameters
block}to block storage
Returns
hash of saved header or error

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<void> kagome::blockchain::BlockStorage::putBlockData ( primitives::BlockNumber  ,
const primitives::BlockData block_data 
)
pure virtual

Saves {

Parameters
data}of block with {
number}to block storage
Returns
result of saving

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<primitives::BlockHash> kagome::blockchain::BlockStorage::putBlockHeader ( const primitives::BlockHeader header)
pure virtual

Saves block header {

Parameters
header}to block storage
Returns
hash of saved header or error

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<void> kagome::blockchain::BlockStorage::putJustification ( const primitives::Justification justification,
const primitives::BlockHash hash,
primitives::BlockNumber  number 
)
pure virtual

Saves {

Parameters
justification}of block with {
number}and {
hash}to block storage
Returns
result of saving

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<void> kagome::blockchain::BlockStorage::putNumberToIndexKey ( const primitives::BlockInfo block)
pure virtual

Saves number-to-block_lookup_key for {

Parameters
block}to block storage
Returns
hash of saved header or error

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<void> kagome::blockchain::BlockStorage::removeBlock ( const primitives::BlockInfo block)
pure virtual

Removes all data of block {

Parameters
block}from block storage
Returns
result of removing

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<void> kagome::blockchain::BlockStorage::removeBlockData ( primitives::BlockNumber  block_number,
const primitives::BlockDataFlags remove_flags 
)
pure virtual

Removes data parts from storage

  • remove_flags - parts to remove
  • number - block number
    Returns
    result of removal

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<void> kagome::blockchain::BlockStorage::removeJustification ( const primitives::BlockHash hash,
primitives::BlockNumber  number 
)
pure virtual

Removes {

Parameters
justification}of block with {
number}and {
hash}from block storage
Returns
result of saving

Implemented in kagome::blockchain::BlockStorageImpl.

virtual outcome::result<void> kagome::blockchain::BlockStorage::setBlockTreeLeaves ( std::vector< primitives::BlockHash leaves)
pure virtual

Saves provided block tree {

Parameters
leaves}
Returns
result of saving

Implemented in kagome::blockchain::BlockStorageImpl.


The documentation for this class was generated from the following file: