[−][src]Struct finality_grandpa::voter::Voter
A future that maintains and multiplexes between different rounds, and caches votes.
This voter also implements the commit protocol. The commit protocol allows a node to broadcast a message that finalizes a given block and includes a set of precommits as proof.
- When a round is completable and we precommitted we start a commit timer and start accepting commit messages;
- When we receive a commit message if it targets a block higher than what we've finalized we validate it and import its precommits if valid;
- When our commit timer triggers we check if we've received any commit message for a block equal to what we've finalized, if we haven't then we broadcast a commit.
Additionally, we also listen to commit messages from rounds that aren't currently running, we validate the commit and dispatch a finalization notification (if any) to the environment.
Methods
impl<H, N, E: Environment<H, N>, GlobalIn, GlobalOut> Voter<H, N, E, GlobalIn, GlobalOut> where
H: Clone + Eq + Ord + Debug,
N: Copy + BlockNumberOps + Debug,
GlobalIn: Stream<Item = CommunicationIn<H, N, E::Signature, E::Id>, Error = E::Error>,
GlobalOut: Sink<SinkItem = CommunicationOut<H, N, E::Signature, E::Id>, SinkError = E::Error>,
[src]
H: Clone + Eq + Ord + Debug,
N: Copy + BlockNumberOps + Debug,
GlobalIn: Stream<Item = CommunicationIn<H, N, E::Signature, E::Id>, Error = E::Error>,
GlobalOut: Sink<SinkItem = CommunicationOut<H, N, E::Signature, E::Id>, SinkError = E::Error>,
pub fn new(
env: Arc<E>,
voters: VoterSet<E::Id>,
global_comms: (GlobalIn, GlobalOut),
last_round_number: u64,
last_round_votes: Vec<SignedMessage<H, N, E::Signature, E::Id>>,
last_round_base: (H, N),
last_finalized: (H, N)
) -> Self
[src]
env: Arc<E>,
voters: VoterSet<E::Id>,
global_comms: (GlobalIn, GlobalOut),
last_round_number: u64,
last_round_votes: Vec<SignedMessage<H, N, E::Signature, E::Id>>,
last_round_base: (H, N),
last_finalized: (H, N)
) -> Self
Create new Voter
tracker with given round number and base block.
Provide data about the last completed round. If there is no known last completed round, the genesis state (round number 0, no votes, genesis base), should be provided. When available, all messages required to complete the last round should be provided.
The input stream for commit messages should provide commits which correspond to known blocks only (including all its precommits). It is also responsible for validating the signature data in commit messages.
Trait Implementations
impl<H, N, E: Environment<H, N>, GlobalIn, GlobalOut> Future for Voter<H, N, E, GlobalIn, GlobalOut> where
H: Clone + Eq + Ord + Debug,
N: Copy + BlockNumberOps + Debug,
GlobalIn: Stream<Item = CommunicationIn<H, N, E::Signature, E::Id>, Error = E::Error>,
GlobalOut: Sink<SinkItem = CommunicationOut<H, N, E::Signature, E::Id>, SinkError = E::Error>,
[src]
H: Clone + Eq + Ord + Debug,
N: Copy + BlockNumberOps + Debug,
GlobalIn: Stream<Item = CommunicationIn<H, N, E::Signature, E::Id>, Error = E::Error>,
GlobalOut: Sink<SinkItem = CommunicationOut<H, N, E::Signature, E::Id>, SinkError = E::Error>,
type Item = ()
The type of value that this future will resolved with if it is successful. Read more
type Error = E::Error
The type of error that this future will resolve with if it fails in a normal fashion. Read more
fn poll(&mut self) -> Poll<(), E::Error>
[src]
fn wait(self) -> Result<Self::Item, Self::Error>
[src]
fn map<F, U>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Item) -> U,
[src]
F: FnOnce(Self::Item) -> U,
fn map_err<F, E>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(Self::Error) -> E,
[src]
F: FnOnce(Self::Error) -> E,
fn from_err<E>(self) -> FromErr<Self, E> where
E: From<Self::Error>,
[src]
E: From<Self::Error>,
fn then<F, B>(self, f: F) -> Then<Self, B, F> where
B: IntoFuture,
F: FnOnce(Result<Self::Item, Self::Error>) -> B,
[src]
B: IntoFuture,
F: FnOnce(Result<Self::Item, Self::Error>) -> B,
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where
B: IntoFuture<Error = Self::Error>,
F: FnOnce(Self::Item) -> B,
[src]
B: IntoFuture<Error = Self::Error>,
F: FnOnce(Self::Item) -> B,
fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F> where
B: IntoFuture<Item = Self::Item>,
F: FnOnce(Self::Error) -> B,
[src]
B: IntoFuture<Item = Self::Item>,
F: FnOnce(Self::Error) -> B,
fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future> where
B: IntoFuture<Item = Self::Item, Error = Self::Error>,
[src]
B: IntoFuture<Item = Self::Item, Error = Self::Error>,
fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future> where
B: IntoFuture,
[src]
B: IntoFuture,
fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future> where
B: IntoFuture<Error = Self::Error>,
[src]
B: IntoFuture<Error = Self::Error>,
fn join3<B, C>(
self,
b: B,
c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
[src]
self,
b: B,
c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
fn join4<B, C, D>(
self,
b: B,
c: C,
d: D
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
[src]
self,
b: B,
c: C,
d: D
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
[src]
self,
b: B,
c: C,
d: D,
e: E
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future> where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
fn into_stream(self) -> IntoStream<Self>
[src]
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoFuture,
<Self::Item as IntoFuture>::Error: From<Self::Error>,
[src]
Self::Item: IntoFuture,
<Self::Item as IntoFuture>::Error: From<Self::Error>,
fn flatten_stream(self) -> FlattenStream<Self> where
Self::Item: Stream,
<Self::Item as Stream>::Error == Self::Error,
[src]
Self::Item: Stream,
<Self::Item as Stream>::Error == Self::Error,
fn fuse(self) -> Fuse<Self>
[src]
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnOnce(&Self::Item),
[src]
F: FnOnce(&Self::Item),
fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
[src]
Self: UnwindSafe,
fn shared(self) -> Shared<Self>
[src]
Auto Trait Implementations
impl<H, N, E, GlobalIn, GlobalOut> Send for Voter<H, N, E, GlobalIn, GlobalOut> where
E: Send + Sync,
GlobalIn: Send,
GlobalOut: Send,
H: Send + Sync,
N: Send + Sync,
<E as Environment<H, N>>::Id: Send,
<E as Environment<H, N>>::In: Send,
<E as Environment<H, N>>::Out: Send,
<E as Environment<H, N>>::Signature: Send,
<E as Environment<H, N>>::Timer: Send,
E: Send + Sync,
GlobalIn: Send,
GlobalOut: Send,
H: Send + Sync,
N: Send + Sync,
<E as Environment<H, N>>::Id: Send,
<E as Environment<H, N>>::In: Send,
<E as Environment<H, N>>::Out: Send,
<E as Environment<H, N>>::Signature: Send,
<E as Environment<H, N>>::Timer: Send,
impl<H, N, E, GlobalIn, GlobalOut> Sync for Voter<H, N, E, GlobalIn, GlobalOut> where
E: Send + Sync,
GlobalIn: Sync,
GlobalOut: Sync,
H: Send + Sync,
N: Send + Sync,
<E as Environment<H, N>>::Id: Send + Sync,
<E as Environment<H, N>>::In: Sync,
<E as Environment<H, N>>::Out: Sync,
<E as Environment<H, N>>::Signature: Send + Sync,
<E as Environment<H, N>>::Timer: Sync,
E: Send + Sync,
GlobalIn: Sync,
GlobalOut: Sync,
H: Send + Sync,
N: Send + Sync,
<E as Environment<H, N>>::Id: Send + Sync,
<E as Environment<H, N>>::In: Sync,
<E as Environment<H, N>>::Out: Sync,
<E as Environment<H, N>>::Signature: Send + Sync,
<E as Environment<H, N>>::Timer: Sync,
impl<H, N, E, GlobalIn, GlobalOut> Unpin for Voter<H, N, E, GlobalIn, GlobalOut> where
GlobalIn: Unpin,
GlobalOut: Unpin,
H: Unpin,
N: Unpin,
<E as Environment<H, N>>::Id: Unpin,
<E as Environment<H, N>>::In: Unpin,
<E as Environment<H, N>>::Out: Unpin,
<E as Environment<H, N>>::Signature: Unpin,
<E as Environment<H, N>>::Timer: Unpin,
GlobalIn: Unpin,
GlobalOut: Unpin,
H: Unpin,
N: Unpin,
<E as Environment<H, N>>::Id: Unpin,
<E as Environment<H, N>>::In: Unpin,
<E as Environment<H, N>>::Out: Unpin,
<E as Environment<H, N>>::Signature: Unpin,
<E as Environment<H, N>>::Timer: Unpin,
impl<H, N, E, GlobalIn, GlobalOut> !UnwindSafe for Voter<H, N, E, GlobalIn, GlobalOut>
impl<H, N, E, GlobalIn, GlobalOut> !RefUnwindSafe for Voter<H, N, E, GlobalIn, GlobalOut>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<F> IntoFuture for F where
F: Future,
[src]
F: Future,