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.
Implementations
impl<H, N, V> VoteGraph<H, N, V> where
H: Eq + Clone + Ord + Debug,
V: for<'a> AddAssign<&'a V> + Default + Clone + Debug,
N: Copy + Debug + BlockNumberOps,
[src]
H: Eq + Clone + Ord + Debug,
V: for<'a> AddAssign<&'a V> + Default + Clone + Debug,
N: Copy + Debug + BlockNumberOps,
pub fn new(base_hash: H, base_number: N, base_node: V) -> Self
[src]
Create a new VoteGraph
with base node as given.
pub fn base(&self) -> (H, N)
[src]
Get the base block.
pub fn adjust_base(&mut self, ancestry_proof: &[H])
[src]
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.
pub fn insert<C: Chain<H, N>, W>(
&mut self,
hash: H,
number: N,
vote: W,
chain: &C
) -> Result<(), Error> where
V: for<'a> AddAssign<&'a W>,
[src]
&mut self,
hash: H,
number: N,
vote: W,
chain: &C
) -> Result<(), Error> where
V: for<'a> AddAssign<&'a W>,
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: N,
condition: F
) -> Option<(H, N)> where
F: Fn(&V) -> bool,
[src]
&'a self,
hash: H,
number: N,
condition: F
) -> Option<(H, N)> where
F: Fn(&V) -> bool,
Find the block with the highest block number in the chain with the given head which fulfills the given condition.
Returns None
if the given head is not in the graph or no node fulfills the
given condition.
pub fn cumulative_vote<'a>(&'a self, hash: H, number: N) -> V
[src]
Find the total vote on a given block.
pub fn find_ghost<'a, F>(
&'a self,
current_best: Option<(H, N)>,
condition: F
) -> Option<(H, N)> where
F: Fn(&V) -> bool,
[src]
&'a self,
current_best: Option<(H, N)>,
condition: F
) -> Option<(H, N)> 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.
Auto Trait Implementations
impl<H, N, V> RefUnwindSafe for VoteGraph<H, N, V> where
H: RefUnwindSafe,
N: RefUnwindSafe,
V: RefUnwindSafe,
H: RefUnwindSafe,
N: RefUnwindSafe,
V: RefUnwindSafe,
impl<H, N, V> Send for VoteGraph<H, N, V> where
H: Send,
N: Send,
V: Send,
H: Send,
N: Send,
V: Send,
impl<H, N, V> Sync for VoteGraph<H, N, V> where
H: Sync,
N: Sync,
V: Sync,
H: Sync,
N: Sync,
V: Sync,
impl<H, N, V> Unpin for VoteGraph<H, N, V> where
H: Unpin,
N: Unpin,
H: Unpin,
N: Unpin,
impl<H, N, V> UnwindSafe for VoteGraph<H, N, V> where
H: RefUnwindSafe + UnwindSafe,
N: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe,
H: RefUnwindSafe + UnwindSafe,
N: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,