Kagome
Polkadot Runtime Engine in C++17
kagome::consensus::grandpa::VoteGraphImpl Class Reference

#include <vote_graph_impl.hpp>

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

Public Member Functions

 VoteGraphImpl (const BlockInfo &base, std::shared_ptr< VoterSet > voter_set, std::shared_ptr< Chain > chain)
 
void adjustBase (const std::vector< BlockHash > &ancestry_proof) override
 
outcome::result< void > insert (VoteType vote_type, const BlockInfo &block, const Id &voter) override
 Insert vote {. More...
 
void remove (VoteType vote_type, const Id &voter) override
 Remove vote {. More...
 
std::optional< BlockInfofindAncestor (VoteType vote_type, const BlockInfo &block, const Condition &condition) const override
 
std::optional< BlockInfofindGhost (VoteType vote_type, const std::optional< BlockInfo > &current_best, const Condition &condition) const override
 
void introduceBranch (const std::vector< primitives::BlockHash > &descendants, const BlockInfo &ancestor)
 
outcome::result< void > append (const BlockInfo &block)
 
Subchain ghostFindMergePoint (VoteType vote_type, const BlockHash &active_node_hash, const Entry &active_node, const std::optional< BlockInfo > &force_constrain, const Condition &condition) const
 
std::optional< std::vector< primitives::BlockHash > > findContainingNodes (const BlockInfo &block) const
 
const BlockInfogetBase () const override
 
const auto & getEntries () const
 
const auto & getHeads () const
 
- Public Member Functions inherited from kagome::consensus::grandpa::VoteGraph
virtual ~VoteGraph ()=default
 

Private Attributes

BlockInfo base_
 
std::shared_ptr< VoterSetvoter_set_
 
std::shared_ptr< Chainchain_
 
log::Logger logger_
 
std::unordered_map< BlockHash, Entry > entries_
 
std::unordered_set< BlockHashheads_
 

Additional Inherited Members

- Public Types inherited from kagome::consensus::grandpa::VoteGraph
using Condition = std::function< bool(const VoteWeight &)>
 
using Comparator = std::function< bool(const VoteWeight &, const VoteWeight &)>
 

Detailed Description

Definition at line 17 of file vote_graph_impl.hpp.

Constructor & Destructor Documentation

kagome::consensus::grandpa::VoteGraphImpl::VoteGraphImpl ( const BlockInfo base,
std::shared_ptr< VoterSet voter_set,
std::shared_ptr< Chain chain 
)

Definition at line 42 of file vote_graph_impl.cpp.

Member Function Documentation

void kagome::consensus::grandpa::VoteGraphImpl::adjustBase ( const std::vector< BlockHash > &  ancestry_proof)
overridevirtual

Adjust the base of the graph. The new base must be an ancestor of the old base.

Provide an ancestry proof from the old base to the new. The proof should be in reverse order from the old base's parent.

Implements kagome::consensus::grandpa::VoteGraph.

Definition at line 414 of file vote_graph_impl.cpp.

outcome::result< void > kagome::consensus::grandpa::VoteGraphImpl::append ( const BlockInfo block)

Definition at line 140 of file vote_graph_impl.cpp.

std::optional< BlockInfo > kagome::consensus::grandpa::VoteGraphImpl::findAncestor ( VoteType  vote_type,
const BlockInfo block,
const Condition condition 
) const
overridevirtual

Find the highest block which is either an ancestor of or equal to the given, which fulfills a condition.

Implements kagome::consensus::grandpa::VoteGraph.

Definition at line 442 of file vote_graph_impl.cpp.

std::optional< std::vector< primitives::BlockHash > > kagome::consensus::grandpa::VoteGraphImpl::findContainingNodes ( const BlockInfo block) const

Definition at line 53 of file vote_graph_impl.cpp.

std::optional< BlockInfo > kagome::consensus::grandpa::VoteGraphImpl::findGhost ( VoteType  vote_type,
const std::optional< BlockInfo > &  current_best,
const Condition condition 
) const
overridevirtual

Find the best GHOST descendant of the given block. Pass a closure used to evaluate the cumulative vote value.

The GHOST (hash, number) returned will be the block with highest number for which the cumulative votes of descendants and itself causes the closure to evaluate to true.

This assumes that the evaluation closure is one which returns true for at most a single descendant of a block, in that only one fork of a block can be "heavy" enough to trigger the threshold.

Returns None when the given current_best does not fulfill the condition.

entries to be processed

Implements kagome::consensus::grandpa::VoteGraph.

Definition at line 259 of file vote_graph_impl.cpp.

const BlockInfo& kagome::consensus::grandpa::VoteGraphImpl::getBase ( ) const
inlineoverridevirtual

Implements kagome::consensus::grandpa::VoteGraph.

Definition at line 96 of file vote_graph_impl.hpp.

const auto& kagome::consensus::grandpa::VoteGraphImpl::getEntries ( ) const
inline

Definition at line 100 of file vote_graph_impl.hpp.

const auto& kagome::consensus::grandpa::VoteGraphImpl::getHeads ( ) const
inline

Definition at line 104 of file vote_graph_impl.hpp.

VoteGraph::Subchain kagome::consensus::grandpa::VoteGraphImpl::ghostFindMergePoint ( VoteType  vote_type,
const BlockHash active_node_hash,
const Entry &  active_node,
const std::optional< BlockInfo > &  force_constrain,
const Condition condition 
) const

Definition at line 342 of file vote_graph_impl.cpp.

outcome::result< void > kagome::consensus::grandpa::VoteGraphImpl::insert ( VoteType  vote_type,
const BlockInfo block,
const Id voter 
)
overridevirtual

Insert vote {.

Parameters
vote_type}of {
voter}for {
block}

Implements kagome::consensus::grandpa::VoteGraph.

Definition at line 92 of file vote_graph_impl.cpp.

void kagome::consensus::grandpa::VoteGraphImpl::introduceBranch ( const std::vector< primitives::BlockHash > &  descendants,
const BlockInfo ancestor 
)

Definition at line 197 of file vote_graph_impl.cpp.

void kagome::consensus::grandpa::VoteGraphImpl::remove ( VoteType  vote_type,
const Id voter 
)
overridevirtual

Remove vote {.

Parameters
vote_type}of {
voter}

Implements kagome::consensus::grandpa::VoteGraph.

Definition at line 130 of file vote_graph_impl.cpp.

Member Data Documentation

BlockInfo kagome::consensus::grandpa::VoteGraphImpl::base_
private

Definition at line 109 of file vote_graph_impl.hpp.

std::shared_ptr<Chain> kagome::consensus::grandpa::VoteGraphImpl::chain_
private

Definition at line 111 of file vote_graph_impl.hpp.

std::unordered_map<BlockHash, Entry> kagome::consensus::grandpa::VoteGraphImpl::entries_
private

Definition at line 114 of file vote_graph_impl.hpp.

std::unordered_set<BlockHash> kagome::consensus::grandpa::VoteGraphImpl::heads_
private

Definition at line 115 of file vote_graph_impl.hpp.

log::Logger kagome::consensus::grandpa::VoteGraphImpl::logger_
private

Definition at line 112 of file vote_graph_impl.hpp.

std::shared_ptr<VoterSet> kagome::consensus::grandpa::VoteGraphImpl::voter_set_
private

Definition at line 110 of file vote_graph_impl.hpp.


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