Trait finality_grandpa::voter::Environment[][src]

pub trait Environment<H: Eq, N: BlockNumberOps>: Chain<H, N> {
    type Timer: Future<Output = Result<(), Self::Error>> + Unpin;
    type Id: Ord + Clone + Eq + Debug;
    type Signature: Eq + Clone;
    type In: Stream<Item = Result<SignedMessage<H, N, Self::Signature, Self::Id>, Self::Error>> + Unpin;
    type Out: Sink<Message<H, N>, Error = Self::Error> + Unpin;
    type Error: From<Error> + Error;
    fn round_data(
        &self,
        round: u64
    ) -> RoundData<Self::Id, Self::Timer, Self::In, Self::Out>;
fn round_commit_timer(&self) -> Self::Timer;
fn proposed(
        &self,
        round: u64,
        propose: PrimaryPropose<H, N>
    ) -> Result<(), Self::Error>;
fn prevoted(
        &self,
        round: u64,
        prevote: Prevote<H, N>
    ) -> Result<(), Self::Error>;
fn precommitted(
        &self,
        round: u64,
        precommit: Precommit<H, N>
    ) -> Result<(), Self::Error>;
fn completed(
        &self,
        round: u64,
        state: RoundState<H, N>,
        base: (H, N),
        votes: &HistoricalVotes<H, N, Self::Signature, Self::Id>
    ) -> Result<(), Self::Error>;
fn concluded(
        &self,
        round: u64,
        state: RoundState<H, N>,
        base: (H, N),
        votes: &HistoricalVotes<H, N, Self::Signature, Self::Id>
    ) -> Result<(), Self::Error>;
fn finalize_block(
        &self,
        hash: H,
        number: N,
        round: u64,
        commit: Commit<H, N, Self::Signature, Self::Id>
    ) -> Result<(), Self::Error>;
fn prevote_equivocation(
        &self,
        round: u64,
        equivocation: Equivocation<Self::Id, Prevote<H, N>, Self::Signature>
    );
fn precommit_equivocation(
        &self,
        round: u64,
        equivocation: Equivocation<Self::Id, Precommit<H, N>, Self::Signature>
    ); }

Necessary environment for a voter.

This encapsulates the database and networking layers of the chain.

Associated Types

type Timer: Future<Output = Result<(), Self::Error>> + Unpin[src]

Associated timer for the Environment. See also round_commit_data.

type Id: Ord + Clone + Eq + Debug[src]

The associated Id for the Environment.

type Signature: Eq + Clone[src]

The associated Signature type for the Environment.

type In: Stream<Item = Result<SignedMessage<H, N, Self::Signature, Self::Id>, Self::Error>> + Unpin[src]

The input stream used to communicate with the outside world.

type Out: Sink<Message<H, N>, Error = Self::Error> + Unpin[src]

The output stream used to communicate with the outside world.

type Error: From<Error> + Error[src]

The associated Error type.

Loading content...

Required methods

fn round_data(
    &self,
    round: u64
) -> RoundData<Self::Id, Self::Timer, Self::In, Self::Out>
[src]

Produce data necessary to start a round of voting. This may also be called with the round number of the most recently completed round, in which case it should yield a valid input stream.

The input stream should provide messages which correspond to known blocks only.

The voting logic will push unsigned messages over-eagerly into the output stream. It is the job of this stream to determine if those messages should be sent (for example, if the process actually controls a permissioned key) and then to sign the message, multicast it to peers, and schedule it to be returned by the In stream.

This allows the voting logic to maintain the invariant that only incoming messages may alter the state, and the logic remains the same regardless of whether a node is a regular voter, the proposer, or simply an observer.

Furthermore, this means that actual logic of creating and verifying signatures is flexible and can be maintained outside this crate.

fn round_commit_timer(&self) -> Self::Timer[src]

Return a timer that will be used to delay the broadcast of a commit message. This delay should not be static to minimize the amount of commit messages that are sent (e.g. random value in [0, 1] seconds).

fn proposed(
    &self,
    round: u64,
    propose: PrimaryPropose<H, N>
) -> Result<(), Self::Error>
[src]

Note that we’ve done a primary proposal in the given round.

fn prevoted(
    &self,
    round: u64,
    prevote: Prevote<H, N>
) -> Result<(), Self::Error>
[src]

Note that we have prevoted in the given round.

fn precommitted(
    &self,
    round: u64,
    precommit: Precommit<H, N>
) -> Result<(), Self::Error>
[src]

Note that we have precommitted in the given round.

fn completed(
    &self,
    round: u64,
    state: RoundState<H, N>,
    base: (H, N),
    votes: &HistoricalVotes<H, N, Self::Signature, Self::Id>
) -> Result<(), Self::Error>
[src]

Note that a round is completed. This is called when a round has been voted in and the next round can start. The round may continue to be run in the background until concluded. Should return an error when something fatal occurs.

fn concluded(
    &self,
    round: u64,
    state: RoundState<H, N>,
    base: (H, N),
    votes: &HistoricalVotes<H, N, Self::Signature, Self::Id>
) -> Result<(), Self::Error>
[src]

Note that a round has concluded. This is called when a round has been completed and additionally, the round’s estimate has been finalized.

There may be more votes than when completed, and it is the responsibility of the Environment implementation to deduplicate. However, the caller guarantees that the votes passed to completed for this round are a prefix of the votes passed here.

fn finalize_block(
    &self,
    hash: H,
    number: N,
    round: u64,
    commit: Commit<H, N, Self::Signature, Self::Id>
) -> Result<(), Self::Error>
[src]

Called when a block should be finalized.

fn prevote_equivocation(
    &self,
    round: u64,
    equivocation: Equivocation<Self::Id, Prevote<H, N>, Self::Signature>
)
[src]

Note that an equivocation in prevotes has occurred.

fn precommit_equivocation(
    &self,
    round: u64,
    equivocation: Equivocation<Self::Id, Precommit<H, N>, Self::Signature>
)
[src]

Note that an equivocation in precommits has occurred.

Loading content...

Implementors

Loading content...