Kagome
Polkadot Runtime Engine in C++17
kagome::consensus::grandpa::Environment Struct Referenceabstract

#include <environment.hpp>

Inheritance diagram for kagome::consensus::grandpa::Environment:
Collaboration diagram for kagome::consensus::grandpa::Environment:

Public Types

using CompleteHandler = std::function< void(outcome::result< MovableRoundState >)>
 

Public Member Functions

 ~Environment () override=default
 
virtual void setJustificationObserver (std::weak_ptr< JustificationObserver > justification_observer)=0
 
virtual outcome::result< void > onCatchUpRequested (const libp2p::peer::PeerId &peer_id, VoterSetId set_id, RoundNumber round_number)=0
 
virtual outcome::result< void > onCatchUpRespond (const libp2p::peer::PeerId &peer_id, VoterSetId set_id, RoundNumber round_number, std::vector< SignedPrevote > prevote_justification, std::vector< SignedPrecommit > precommit_justification, BlockInfo best_final_candidate)=0
 
virtual void sendState (const libp2p::peer::PeerId &peer_id, const MovableRoundState &state, VoterSetId voter_set_id)=0
 
virtual outcome::result< void > onVoted (RoundNumber round, VoterSetId set_id, const SignedMessage &vote)=0
 
virtual outcome::result< void > onCommitted (RoundNumber round, VoterSetId voter_ser_id, const BlockInfo &vote, const GrandpaJustification &justification)=0
 
virtual outcome::result< void > onNeighborMessageSent (RoundNumber round, VoterSetId set_id, BlockNumber last_finalized)=0
 
virtual outcome::result< void > applyJustification (const BlockInfo &block_info, const primitives::Justification &justification)=0
 
virtual outcome::result< void > finalize (VoterSetId id, const GrandpaJustification &justification)=0
 
virtual outcome::result< GrandpaJustificationgetJustification (const BlockHash &block_hash)=0
 
- Public Member Functions inherited from kagome::consensus::grandpa::Chain
virtual ~Chain ()=default
 
virtual outcome::result< bool > hasBlock (const primitives::BlockHash &block) const =0
 Checks if {. More...
 
virtual outcome::result< std::vector< primitives::BlockHash > > getAncestry (const primitives::BlockHash &base, const primitives::BlockHash &block) const =0
 Get the ancestry of a {. More...
 
virtual bool hasAncestry (const primitives::BlockHash &base, const primitives::BlockHash &block) const =0
 Check if block is ancestor for second one. More...
 
virtual outcome::result< BlockInfobestChainContaining (const primitives::BlockHash &base, std::optional< VoterSetId > voter_set_id) const =0
 
bool isEqualOrDescendOf (const primitives::BlockHash &base, const primitives::BlockHash &block) const
 

Detailed Description

Necessary environment for a voter. This encapsulates the database and networking layers of the chain.

Definition at line 42 of file environment.hpp.

Member Typedef Documentation

using kagome::consensus::grandpa::Environment::CompleteHandler = std::function<void(outcome::result<MovableRoundState>)>

Definition at line 44 of file environment.hpp.

Constructor & Destructor Documentation

kagome::consensus::grandpa::Environment::~Environment ( )
overridedefault

Member Function Documentation

virtual outcome::result<void> kagome::consensus::grandpa::Environment::applyJustification ( const BlockInfo block_info,
const primitives::Justification justification 
)
pure virtual

Validate provided {

Parameters
justification}for finalization {
block}.If it valid finalize {
block}and save {
justification}in storage.
blockis observed block info
justificationjustification of finalization of provided block
Returns
nothing or on error

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual outcome::result<void> kagome::consensus::grandpa::Environment::finalize ( VoterSetId  id,
const GrandpaJustification justification 
)
pure virtual

Triggered when blovk

Parameters
blockjustified by
justificationshould be applied to the storage

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual outcome::result<GrandpaJustification> kagome::consensus::grandpa::Environment::getJustification ( const BlockHash block_hash)
pure virtual

Returns justification for given block

Parameters
block_hashhash of the block that we are trying to get justification for
Returns
GrandpaJustification containing signed precommits for given block if there is such justification. Error otherwise

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual outcome::result<void> kagome::consensus::grandpa::Environment::onCatchUpRequested ( const libp2p::peer::PeerId &  peer_id,
VoterSetId  set_id,
RoundNumber  round_number 
)
pure virtual

Make catch-up-request

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual outcome::result<void> kagome::consensus::grandpa::Environment::onCatchUpRespond ( const libp2p::peer::PeerId &  peer_id,
VoterSetId  set_id,
RoundNumber  round_number,
std::vector< SignedPrevote prevote_justification,
std::vector< SignedPrecommit precommit_justification,
BlockInfo  best_final_candidate 
)
pure virtual

Make catch-up-response

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual outcome::result<void> kagome::consensus::grandpa::Environment::onCommitted ( RoundNumber  round,
VoterSetId  voter_ser_id,
const BlockInfo vote,
const GrandpaJustification justification 
)
pure virtual

Triggered when current peer appears in given round and has given voter_ser_id intends to send committed vote justified by provided justification

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual outcome::result<void> kagome::consensus::grandpa::Environment::onNeighborMessageSent ( RoundNumber  round,
VoterSetId  set_id,
BlockNumber  last_finalized 
)
pure virtual

Triggered when current peer should send neighbor message

Parameters
roundcurrent round
set_idid of actual voter set
last_finalizedlast known finalized block

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual outcome::result<void> kagome::consensus::grandpa::Environment::onVoted ( RoundNumber  round,
VoterSetId  set_id,
const SignedMessage vote 
)
pure virtual

Note that we've done a vote in the given round. Triggered when current peer appears in provided round with provided set_id and given vote is ready to be sent.

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual void kagome::consensus::grandpa::Environment::sendState ( const libp2p::peer::PeerId &  peer_id,
const MovableRoundState state,
VoterSetId  voter_set_id 
)
pure virtual

Propagate round state

Implemented in kagome::consensus::grandpa::EnvironmentImpl.

virtual void kagome::consensus::grandpa::Environment::setJustificationObserver ( std::weak_ptr< JustificationObserver justification_observer)
pure virtual

Sets back-link to Grandpa

Implemented in kagome::consensus::grandpa::EnvironmentImpl.


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