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

#include <vote_graph.hpp>

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

Classes

struct  Entry
 
struct  Subchain
 

Public Types

using Condition = std::function< bool(const VoteWeight &)>
 
using Comparator = std::function< bool(const VoteWeight &, const VoteWeight &)>
 

Public Member Functions

virtual ~VoteGraph ()=default
 
virtual const BlockInfogetBase () const =0
 
virtual void adjustBase (const std::vector< BlockHash > &ancestry_proof)=0
 
virtual outcome::result< void > insert (VoteType vote_type, const BlockInfo &block, const Id &voter)=0
 Insert vote {. More...
 
virtual void remove (VoteType vote_type, const Id &voter)=0
 Remove vote {. More...
 
virtual std::optional< BlockInfofindAncestor (VoteType vote_type, const BlockInfo &block, const Condition &condition) const =0
 
virtual std::optional< BlockInfofindGhost (VoteType vote_type, const std::optional< BlockInfo > &current_best, const Condition &condition) const =0
 

Detailed Description

Keeps track of obtained votes. Provides convenient interfaces for getting ancestry of the votes and calculating ghost vote

Definition at line 21 of file vote_graph.hpp.


Class Documentation

struct kagome::consensus::grandpa::VoteGraph::Subchain

Definition at line 54 of file vote_graph.hpp.

Collaboration diagram for kagome::consensus::grandpa::VoteGraph::Subchain:
Class Members
BlockNumber best_number
vector< BlockHash > hashes

Member Typedef Documentation

using kagome::consensus::grandpa::VoteGraph::Comparator = std::function<bool(const VoteWeight &, const VoteWeight &)>

Definition at line 63 of file vote_graph.hpp.

using kagome::consensus::grandpa::VoteGraph::Condition = std::function<bool(const VoteWeight &)>

Definition at line 61 of file vote_graph.hpp.

Constructor & Destructor Documentation

virtual kagome::consensus::grandpa::VoteGraph::~VoteGraph ( )
virtualdefault

Member Function Documentation

virtual void kagome::consensus::grandpa::VoteGraph::adjustBase ( const std::vector< BlockHash > &  ancestry_proof)
pure virtual

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.

Implemented in kagome::consensus::grandpa::VoteGraphImpl.

virtual std::optional<BlockInfo> kagome::consensus::grandpa::VoteGraph::findAncestor ( VoteType  vote_type,
const BlockInfo block,
const Condition condition 
) const
pure virtual

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

Implemented in kagome::consensus::grandpa::VoteGraphImpl.

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

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.

Implemented in kagome::consensus::grandpa::VoteGraphImpl.

virtual const BlockInfo& kagome::consensus::grandpa::VoteGraph::getBase ( ) const
pure virtual
virtual outcome::result<void> kagome::consensus::grandpa::VoteGraph::insert ( VoteType  vote_type,
const BlockInfo block,
const Id voter 
)
pure virtual

Insert vote {.

Parameters
vote_type}of {
voter}for {
block}

Implemented in kagome::consensus::grandpa::VoteGraphImpl.

virtual void kagome::consensus::grandpa::VoteGraph::remove ( VoteType  vote_type,
const Id voter 
)
pure virtual

Remove vote {.

Parameters
vote_type}of {
voter}

Implemented in kagome::consensus::grandpa::VoteGraphImpl.


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