pub struct VoteGraph<H: Ord + Eq, N, V> { /* private fields */ }
Expand description

Maintains a DAG of blocks in the chain which have votes attached to them, and vote data which is accumulated along edges.

Implementations

Create a new VoteGraph with base node as given.

Get the base block.

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.

Insert a vote with given value into the graph at given hash and number.

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.

Find the total vote on a given block.

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.