Kagome
Polkadot Runtime Engine in C++17
|
#include <vote_graph_impl.hpp>
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< BlockInfo > | findAncestor (VoteType vote_type, const BlockInfo &block, const Condition &condition) const override |
std::optional< BlockInfo > | findGhost (VoteType vote_type, const std::optional< BlockInfo > ¤t_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 BlockInfo & | getBase () 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< VoterSet > | voter_set_ |
std::shared_ptr< Chain > | chain_ |
log::Logger | logger_ |
std::unordered_map< BlockHash, Entry > | entries_ |
std::unordered_set< BlockHash > | heads_ |
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 &)> |
Definition at line 17 of file vote_graph_impl.hpp.
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.
|
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.
|
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.
|
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.
|
inlineoverridevirtual |
Implements kagome::consensus::grandpa::VoteGraph.
Definition at line 96 of file vote_graph_impl.hpp.
|
inline |
Definition at line 100 of file vote_graph_impl.hpp.
|
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.
|
overridevirtual |
Insert vote {.
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.
|
overridevirtual |
Remove vote {.
vote_type} | of { |
voter} |
Implements kagome::consensus::grandpa::VoteGraph.
Definition at line 130 of file vote_graph_impl.cpp.
|
private |
Definition at line 109 of file vote_graph_impl.hpp.
|
private |
Definition at line 111 of file vote_graph_impl.hpp.
|
private |
Definition at line 114 of file vote_graph_impl.hpp.
|
private |
Definition at line 115 of file vote_graph_impl.hpp.
|
private |
Definition at line 112 of file vote_graph_impl.hpp.
|
private |
Definition at line 110 of file vote_graph_impl.hpp.