Struct finality_grandpa::vote_graph::VoteGraph [−][src]
Maintains a DAG of blocks in the chain which have votes attached to them, and vote data which is accumulated along edges.
Methods
impl<H, V> VoteGraph<H, V> where
H: Hash + Eq + Clone + Ord + Debug,
V: AddAssign + Default + Clone + Debug,
[src]
impl<H, V> VoteGraph<H, V> where
H: Hash + Eq + Clone + Ord + Debug,
V: AddAssign + Default + Clone + Debug,
pub fn new(base_hash: H, base_number: u32) -> Self
[src]
pub fn new(base_hash: H, base_number: u32) -> Self
Create a new VoteGraph
with base node as given.
pub fn base(&self) -> (H, u32)
[src]
pub fn base(&self) -> (H, u32)
Get the base block.
pub fn insert<C: Chain<H>>(
&mut self,
hash: H,
number: u32,
vote: V,
chain: &C
) -> Result<(), Error>
[src]
pub fn insert<C: Chain<H>>(
&mut self,
hash: H,
number: u32,
vote: V,
chain: &C
) -> Result<(), Error>
Insert a vote with given value into the graph at given hash and number.
pub fn find_ancestor<'a, F>(
&'a self,
hash: H,
number: u32,
condition: F
) -> Option<(H, u32)> where
F: Fn(&V) -> bool,
[src]
pub fn find_ancestor<'a, F>(
&'a self,
hash: H,
number: u32,
condition: F
) -> Option<(H, u32)> where
F: Fn(&V) -> bool,
Find the highest block which is either an ancestor of or equal to the given, which fulfills a condition.
pub fn find_ghost<'a, F>(
&'a self,
current_best: Option<(H, u32)>,
condition: F
) -> Option<(H, u32)> where
F: Fn(&V) -> bool,
[src]
pub fn find_ghost<'a, F>(
&'a self,
current_best: Option<(H, u32)>,
condition: F
) -> Option<(H, u32)> where
F: Fn(&V) -> bool,
Find the best GHOST descendent 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 descendents 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 descendent 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.