Kagome
Polkadot Runtime Engine in C++17
kagome::api::ChainApiImpl Class Reference

#include <chain_api_impl.hpp>

Inheritance diagram for kagome::api::ChainApiImpl:
Collaboration diagram for kagome::api::ChainApiImpl:

Public Types

enum  Error { Error::BLOCK_NOT_FOUND = 1, Error::HEADER_NOT_FOUND }
 
- Public Types inherited from kagome::api::ChainApi
using BlockNumber = primitives::BlockNumber
 
using BlockHash = kagome::primitives::BlockHash
 
using ValueType = boost::variant< BlockNumber, std::string >
 

Public Member Functions

 ~ChainApiImpl () override=default
 
 ChainApiImpl (std::shared_ptr< blockchain::BlockHeaderRepository > block_repo, std::shared_ptr< blockchain::BlockTree > block_tree, std::shared_ptr< blockchain::BlockStorage > block_storage)
 
void setApiService (std::shared_ptr< api::ApiService > const &api_service) override
 
outcome::result< BlockHashgetBlockHash () const override
 
outcome::result< BlockHashgetBlockHash (BlockNumber value) const override
 
outcome::result< BlockHashgetBlockHash (std::string_view value) const override
 
outcome::result< std::vector< BlockHash > > getBlockHash (gsl::span< const ValueType > values) const override
 
outcome::result< primitives::BlockHeadergetHeader (std::string_view hash) override
 
outcome::result< primitives::BlockHeadergetHeader () override
 
outcome::result< primitives::BlockDatagetBlock (std::string_view hash) override
 
outcome::result< primitives::BlockDatagetBlock () override
 
outcome::result< primitives::BlockHashgetFinalizedHead () const override
 
outcome::result< uint32_t > subscribeFinalizedHeads () override
 
outcome::result< void > unsubscribeFinalizedHeads (uint32_t subscription_id) override
 
outcome::result< uint32_t > subscribeNewHeads () override
 
outcome::result< void > unsubscribeNewHeads (uint32_t subscription_id) override
 
- Public Member Functions inherited from kagome::api::ChainApi
virtual ~ChainApi ()=default
 

Private Attributes

std::shared_ptr< blockchain::BlockHeaderRepositoryheader_repo_
 
std::shared_ptr< blockchain::BlockTreeblock_tree_
 
std::weak_ptr< api::ApiServiceapi_service_
 
std::shared_ptr< blockchain::BlockStorageblock_storage_
 

Detailed Description

Definition at line 18 of file chain_api_impl.hpp.

Member Enumeration Documentation

Enumerator
BLOCK_NOT_FOUND 
HEADER_NOT_FOUND 

Definition at line 20 of file chain_api_impl.hpp.

Constructor & Destructor Documentation

kagome::api::ChainApiImpl::~ChainApiImpl ( )
overridedefault
kagome::api::ChainApiImpl::ChainApiImpl ( std::shared_ptr< blockchain::BlockHeaderRepository block_repo,
std::shared_ptr< blockchain::BlockTree block_tree,
std::shared_ptr< blockchain::BlockStorage block_storage 
)

Definition at line 29 of file chain_api_impl.cpp.

Member Function Documentation

outcome::result< primitives::BlockData > kagome::api::ChainApiImpl::getBlock ( std::string_view  hash)
overridevirtual
Parameters
hashhex-string of a block to retrieve

Implements kagome::api::ChainApi.

Definition at line 86 of file chain_api_impl.cpp.

outcome::result< primitives::BlockData > kagome::api::ChainApiImpl::getBlock ( )
overridevirtual

Returns header of a last finalized block.

Implements kagome::api::ChainApi.

Definition at line 94 of file chain_api_impl.cpp.

outcome::result< BlockHash > kagome::api::ChainApiImpl::getBlockHash ( ) const
overridevirtual
Returns
last finalized block hash

Implements kagome::api::ChainApi.

Definition at line 42 of file chain_api_impl.cpp.

outcome::result< common::Hash256 > kagome::api::ChainApiImpl::getBlockHash ( BlockNumber  block_number) const
overridevirtual
Parameters
block_numberblock number
Returns
block hash by number

Implements kagome::api::ChainApi.

Definition at line 46 of file chain_api_impl.cpp.

outcome::result< BlockHash > kagome::api::ChainApiImpl::getBlockHash ( std::string_view  hex_number) const
overridevirtual
Parameters
hex_numberhex-encoded block number
Returns
block hash by number

Implements kagome::api::ChainApi.

Definition at line 57 of file chain_api_impl.cpp.

outcome::result< std::vector< BlockHash > > kagome::api::ChainApiImpl::getBlockHash ( gsl::span< const ValueType values) const
overridevirtual
Parameters
valuesmixed values array either of block number of hex-encoded block number as string
Returns
array of block hashes for numbers

Implements kagome::api::ChainApi.

Definition at line 67 of file chain_api_impl.cpp.

outcome::result< primitives::BlockHash > kagome::api::ChainApiImpl::getFinalizedHead ( ) const
overridevirtual

Get hash of the last finalized block in the canon chain.

Returns
The hash of the last finalized block

Implements kagome::api::ChainApi.

Definition at line 101 of file chain_api_impl.cpp.

outcome::result<primitives::BlockHeader> kagome::api::ChainApiImpl::getHeader ( std::string_view  hash)
inlineoverridevirtual
Parameters
hashhex-string of a block to retrieve

Implements kagome::api::ChainApi.

Definition at line 44 of file chain_api_impl.hpp.

outcome::result<primitives::BlockHeader> kagome::api::ChainApiImpl::getHeader ( )
inlineoverridevirtual

Returns header of a last finalized block.

Implements kagome::api::ChainApi.

Definition at line 50 of file chain_api_impl.hpp.

void kagome::api::ChainApiImpl::setApiService ( std::shared_ptr< api::ApiService > const &  api_service)
overridevirtual

Implements kagome::api::ChainApi.

Definition at line 51 of file chain_api_impl.cpp.

outcome::result< uint32_t > kagome::api::ChainApiImpl::subscribeFinalizedHeads ( )
overridevirtual

Subscribes to events of Finalized Heads type.

Returns
id of the subscription

Implements kagome::api::ChainApi.

Definition at line 106 of file chain_api_impl.cpp.

outcome::result< uint32_t > kagome::api::ChainApiImpl::subscribeNewHeads ( )
overridevirtual

Subscribes to events of New Heads type

Returns
id of the subscription

Implements kagome::api::ChainApi.

Definition at line 126 of file chain_api_impl.cpp.

outcome::result< void > kagome::api::ChainApiImpl::unsubscribeFinalizedHeads ( uint32_t  subscription_id)
overridevirtual

Unsubscribes from events of Finalized Heads type.

Implements kagome::api::ChainApi.

Definition at line 114 of file chain_api_impl.cpp.

outcome::result< void > kagome::api::ChainApiImpl::unsubscribeNewHeads ( uint32_t  subscription_id)
overridevirtual

Unsubscribes from events of New Heads type.

Implements kagome::api::ChainApi.

Definition at line 134 of file chain_api_impl.cpp.

Member Data Documentation

std::weak_ptr<api::ApiService> kagome::api::ChainApiImpl::api_service_
private

Definition at line 72 of file chain_api_impl.hpp.

std::shared_ptr<blockchain::BlockStorage> kagome::api::ChainApiImpl::block_storage_
private

Definition at line 73 of file chain_api_impl.hpp.

std::shared_ptr<blockchain::BlockTree> kagome::api::ChainApiImpl::block_tree_
private

Definition at line 71 of file chain_api_impl.hpp.

std::shared_ptr<blockchain::BlockHeaderRepository> kagome::api::ChainApiImpl::header_repo_
private

Definition at line 70 of file chain_api_impl.hpp.


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