Kagome
Polkadot Runtime Engine in C++17
kagome::consensus::babe::BabeConfigRepositoryImpl Class Referencefinal

#include <babe_config_repository_impl.hpp>

Inheritance diagram for kagome::consensus::babe::BabeConfigRepositoryImpl:
Collaboration diagram for kagome::consensus::babe::BabeConfigRepositoryImpl:

Public Member Functions

 BabeConfigRepositoryImpl (const std::shared_ptr< application::AppStateManager > &app_state_manager, std::shared_ptr< storage::BufferStorage > persistent_storage, std::shared_ptr< blockchain::BlockTree > block_tree, std::shared_ptr< blockchain::BlockHeaderRepository > header_repo, std::shared_ptr< runtime::BabeApi > babe_api, std::shared_ptr< crypto::Hasher > hasher, primitives::events::ChainSubscriptionEnginePtr chain_events_engine, const primitives::GenesisBlockHeader &genesis_block_header, const BabeClock &clock)
 
bool prepare ()
 
outcome::result< void > onDigest (const primitives::BlockInfo &block, const consensus::BabeBlockHeader &digest) override
 
outcome::result< void > onDigest (const primitives::BlockInfo &block, const primitives::BabeDigest &digest) override
 
void cancel (const primitives::BlockInfo &block) override
 
BabeDuration slotDuration () const override
 
EpochLength epochLength () const override
 
std::shared_ptr< const primitives::BabeConfigurationconfig (const primitives::BlockInfo &parent_block, consensus::EpochNumber epoch_number) override
 
BabeSlotNumber syncEpoch (std::function< std::tuple< BabeSlotNumber, bool >()> &&f) override
 
BabeSlotNumber getCurrentSlot () const override
 
BabeTimePoint slotStartTime (BabeSlotNumber slot) const override
 
BabeDuration remainToStartOfSlot (BabeSlotNumber slot) const override
 
BabeTimePoint slotFinishTime (BabeSlotNumber slot) const override
 
BabeDuration remainToFinishOfSlot (BabeSlotNumber slot) const override
 
EpochNumber slotToEpoch (BabeSlotNumber slot) const override
 
BabeSlotNumber slotInEpoch (BabeSlotNumber slot) const override
 
- Public Member Functions inherited from kagome::consensus::babe::BabeConfigRepository
virtual ~BabeConfigRepository ()=default
 
- Public Member Functions inherited from kagome::consensus::BabeDigestObserver
virtual ~BabeDigestObserver ()=default
 
- Public Member Functions inherited from kagome::consensus::BabeUtil
virtual ~BabeUtil ()=default
 

Private Member Functions

outcome::result< void > load ()
 
outcome::result< void > save ()
 
void prune (const primitives::BlockInfo &block)
 
outcome::result< void > onNextEpochData (const primitives::BlockInfo &block, const primitives::NextEpochData &msg)
 
outcome::result< void > onNextConfigData (const primitives::BlockInfo &block, const primitives::NextConfigDataV1 &msg)
 
std::shared_ptr< BabeConfigNodegetNode (const primitives::BlockInfo &block) const
 Find schedule_node according to the block. More...
 
bool directChainExists (const primitives::BlockInfo &ancestor, const primitives::BlockInfo &descendant) const
 Check if one block is direct ancestor of second one. More...
 
BabeSlotNumber getFirstBlockSlotNumber ()
 

Private Attributes

std::shared_ptr< storage::BufferStoragepersistent_storage_
 
std::shared_ptr< blockchain::BlockTreeblock_tree_
 
std::shared_ptr< blockchain::BlockHeaderRepositoryheader_repo_
 
std::shared_ptr< runtime::BabeApibabe_api_
 
std::shared_ptr< crypto::Hasherhasher_
 
std::shared_ptr< primitives::events::ChainEventSubscriberchain_sub_
 
primitives::BlockHash genesis_block_hash_
 
const BabeDuration slot_duration_ {}
 
const EpochLength epoch_length_ {}
 
std::shared_ptr< BabeConfigNoderoot_
 
primitives::BlockNumber last_saved_state_block_ = 0
 
const BabeClockclock_
 
std::optional< BabeSlotNumberfirst_block_slot_number_
 
bool is_first_block_finalized_ = false
 
log::Logger logger_
 

Static Private Attributes

static const primitives::BlockNumber kSavepointEachSuchBlock = 100000
 

Detailed Description

Definition at line 34 of file babe_config_repository_impl.hpp.

Constructor & Destructor Documentation

kagome::consensus::babe::BabeConfigRepositoryImpl::BabeConfigRepositoryImpl ( const std::shared_ptr< application::AppStateManager > &  app_state_manager,
std::shared_ptr< storage::BufferStorage persistent_storage,
std::shared_ptr< blockchain::BlockTree block_tree,
std::shared_ptr< blockchain::BlockHeaderRepository header_repo,
std::shared_ptr< runtime::BabeApi babe_api,
std::shared_ptr< crypto::Hasher hasher,
primitives::events::ChainSubscriptionEnginePtr  chain_events_engine,
const primitives::GenesisBlockHeader genesis_block_header,
const BabeClock clock 
)

Definition at line 22 of file babe_config_repository_impl.cpp.

Member Function Documentation

void kagome::consensus::babe::BabeConfigRepositoryImpl::cancel ( const primitives::BlockInfo block)
overridevirtual
std::shared_ptr< const primitives::BabeConfiguration > kagome::consensus::babe::BabeConfigRepositoryImpl::config ( const primitives::BlockInfo parent_block,
consensus::EpochNumber  epoch_number 
)
overridevirtual

Returns actual babe configuration

Returns
actual babe configuration

Implements kagome::consensus::babe::BabeConfigRepository.

Definition at line 440 of file babe_config_repository_impl.cpp.

bool kagome::consensus::babe::BabeConfigRepositoryImpl::directChainExists ( const primitives::BlockInfo ancestor,
const primitives::BlockInfo descendant 
) const
private

Check if one block is direct ancestor of second one.

Parameters
ancestor- hash of block, which is at the top of the chain
descendant- hash of block, which is the bottom of the chain
Returns
true if
Parameters
ancestoris direct ancestor of
descendant

Definition at line 630 of file babe_config_repository_impl.cpp.

EpochLength kagome::consensus::babe::BabeConfigRepositoryImpl::epochLength ( ) const
overridevirtual

Returns epoch length in number of slot

Returns
slot duration

Implements kagome::consensus::babe::BabeConfigRepository.

Definition at line 455 of file babe_config_repository_impl.cpp.

BabeSlotNumber kagome::consensus::babe::BabeConfigRepositoryImpl::getCurrentSlot ( ) const
overridevirtual
Returns
current unix time slot number

Implements kagome::consensus::BabeUtil.

Definition at line 734 of file babe_config_repository_impl.cpp.

BabeSlotNumber kagome::consensus::babe::BabeConfigRepositoryImpl::getFirstBlockSlotNumber ( )
private

Definition at line 764 of file babe_config_repository_impl.cpp.

std::shared_ptr< BabeConfigNode > kagome::consensus::babe::BabeConfigRepositoryImpl::getNode ( const primitives::BlockInfo block) const
private

Find schedule_node according to the block.

Parameters
blockfor which to find the schedule node
Returns
oldest schedule_node according to the block

Definition at line 602 of file babe_config_repository_impl.cpp.

outcome::result< void > kagome::consensus::babe::BabeConfigRepositoryImpl::load ( )
private

Definition at line 91 of file babe_config_repository_impl.cpp.

outcome::result< void > kagome::consensus::babe::BabeConfigRepositoryImpl::onDigest ( const primitives::BlockInfo block,
const consensus::BabeBlockHeader digest 
)
overridevirtual

Observes BabeDigest of block

Parameters
block- block digest of which observed
digest- BabeBlockHeader as decoded content of PreRuntime digest

Implements kagome::consensus::BabeDigestObserver.

Definition at line 460 of file babe_config_repository_impl.cpp.

outcome::result< void > kagome::consensus::babe::BabeConfigRepositoryImpl::onDigest ( const primitives::BlockInfo block,
const primitives::BabeDigest digest 
)
overridevirtual

Observes BabeDigest of block

Parameters
block- block digest of which observed
digest- BabeDigest as particular variant of ConsensusLog digest

Implements kagome::consensus::BabeDigestObserver.

Definition at line 494 of file babe_config_repository_impl.cpp.

outcome::result< void > kagome::consensus::babe::BabeConfigRepositoryImpl::onNextConfigData ( const primitives::BlockInfo block,
const primitives::NextConfigDataV1 msg 
)
private

Definition at line 579 of file babe_config_repository_impl.cpp.

outcome::result< void > kagome::consensus::babe::BabeConfigRepositoryImpl::onNextEpochData ( const primitives::BlockInfo block,
const primitives::NextEpochData msg 
)
private

Definition at line 556 of file babe_config_repository_impl.cpp.

bool kagome::consensus::babe::BabeConfigRepositoryImpl::prepare ( )

Definition at line 55 of file babe_config_repository_impl.cpp.

void kagome::consensus::babe::BabeConfigRepositoryImpl::prune ( const primitives::BlockInfo block)
private

Definition at line 647 of file babe_config_repository_impl.cpp.

BabeDuration kagome::consensus::babe::BabeConfigRepositoryImpl::remainToFinishOfSlot ( BabeSlotNumber  slot) const
overridevirtual
Returns
duration to finish of slot #{
Parameters
slot}

Implements kagome::consensus::BabeUtil.

Definition at line 759 of file babe_config_repository_impl.cpp.

BabeDuration kagome::consensus::babe::BabeConfigRepositoryImpl::remainToStartOfSlot ( BabeSlotNumber  slot) const
overridevirtual
Returns
duration to start of slot #{
Parameters
slot}

Implements kagome::consensus::BabeUtil.

Definition at line 744 of file babe_config_repository_impl.cpp.

outcome::result< void > kagome::consensus::babe::BabeConfigRepositoryImpl::save ( )
private

Definition at line 368 of file babe_config_repository_impl.cpp.

BabeDuration kagome::consensus::babe::BabeConfigRepositoryImpl::slotDuration ( ) const
overridevirtual

Returns duration of slot in milliseconds

Returns
slot duration

Implements kagome::consensus::babe::BabeConfigRepository.

Definition at line 449 of file babe_config_repository_impl.cpp.

BabeTimePoint kagome::consensus::babe::BabeConfigRepositoryImpl::slotFinishTime ( BabeSlotNumber  slot) const
overridevirtual
Returns
timepoint of finish of slot #{
Parameters
slot}

Implements kagome::consensus::BabeUtil.

Definition at line 754 of file babe_config_repository_impl.cpp.

BabeSlotNumber kagome::consensus::babe::BabeConfigRepositoryImpl::slotInEpoch ( BabeSlotNumber  slot_number) const
overridevirtual
Returns
ordinal number of the slot in the corresponding epoch by provided {
Parameters
slot_number}

Implements kagome::consensus::BabeUtil.

Definition at line 781 of file babe_config_repository_impl.cpp.

BabeTimePoint kagome::consensus::babe::BabeConfigRepositoryImpl::slotStartTime ( BabeSlotNumber  slot) const
overridevirtual
Returns
timepoint of start of slot #{
Parameters
slot}

Implements kagome::consensus::BabeUtil.

Definition at line 739 of file babe_config_repository_impl.cpp.

EpochNumber kagome::consensus::babe::BabeConfigRepositoryImpl::slotToEpoch ( BabeSlotNumber  slot_number) const
overridevirtual
Returns
number of epoch by provided {
Parameters
slot_number}

Implements kagome::consensus::BabeUtil.

Definition at line 772 of file babe_config_repository_impl.cpp.

BabeSlotNumber kagome::consensus::babe::BabeConfigRepositoryImpl::syncEpoch ( std::function< std::tuple< BabeSlotNumber, bool >()> &&  f)
overridevirtual

Init inner state by call {

Parameters
f}returning first block slot and flag if first block is already finalized

Implements kagome::consensus::BabeUtil.

Definition at line 720 of file babe_config_repository_impl.cpp.

Member Data Documentation

std::shared_ptr<runtime::BabeApi> kagome::consensus::babe::BabeConfigRepositoryImpl::babe_api_
private

Definition at line 127 of file babe_config_repository_impl.hpp.

std::shared_ptr<blockchain::BlockTree> kagome::consensus::babe::BabeConfigRepositoryImpl::block_tree_
private

Definition at line 125 of file babe_config_repository_impl.hpp.

std::shared_ptr<primitives::events::ChainEventSubscriber> kagome::consensus::babe::BabeConfigRepositoryImpl::chain_sub_
private

Definition at line 129 of file babe_config_repository_impl.hpp.

const BabeClock& kagome::consensus::babe::BabeConfigRepositoryImpl::clock_
private

Definition at line 138 of file babe_config_repository_impl.hpp.

const EpochLength kagome::consensus::babe::BabeConfigRepositoryImpl::epoch_length_ {}
private

Definition at line 133 of file babe_config_repository_impl.hpp.

std::optional<BabeSlotNumber> kagome::consensus::babe::BabeConfigRepositoryImpl::first_block_slot_number_
private

Definition at line 139 of file babe_config_repository_impl.hpp.

primitives::BlockHash kagome::consensus::babe::BabeConfigRepositoryImpl::genesis_block_hash_
private

Definition at line 130 of file babe_config_repository_impl.hpp.

std::shared_ptr<crypto::Hasher> kagome::consensus::babe::BabeConfigRepositoryImpl::hasher_
private

Definition at line 128 of file babe_config_repository_impl.hpp.

std::shared_ptr<blockchain::BlockHeaderRepository> kagome::consensus::babe::BabeConfigRepositoryImpl::header_repo_
private

Definition at line 126 of file babe_config_repository_impl.hpp.

bool kagome::consensus::babe::BabeConfigRepositoryImpl::is_first_block_finalized_ = false
private

Definition at line 140 of file babe_config_repository_impl.hpp.

const primitives::BlockNumber kagome::consensus::babe::BabeConfigRepositoryImpl::kSavepointEachSuchBlock = 100000
staticprivate

Definition at line 39 of file babe_config_repository_impl.hpp.

primitives::BlockNumber kagome::consensus::babe::BabeConfigRepositoryImpl::last_saved_state_block_ = 0
private

Definition at line 136 of file babe_config_repository_impl.hpp.

log::Logger kagome::consensus::babe::BabeConfigRepositoryImpl::logger_
private

Definition at line 142 of file babe_config_repository_impl.hpp.

std::shared_ptr<storage::BufferStorage> kagome::consensus::babe::BabeConfigRepositoryImpl::persistent_storage_
private

Definition at line 124 of file babe_config_repository_impl.hpp.

std::shared_ptr<BabeConfigNode> kagome::consensus::babe::BabeConfigRepositoryImpl::root_
private

Definition at line 135 of file babe_config_repository_impl.hpp.

const BabeDuration kagome::consensus::babe::BabeConfigRepositoryImpl::slot_duration_ {}
private

Definition at line 132 of file babe_config_repository_impl.hpp.


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