[−][src]Trait finality_grandpa::voter::Environment
Necessary environment for a voter.
This encapsulates the database and networking layers of the chain.
Associated Types
type Timer: Future<Item = (), Error = Self::Error>
type Id: Hash + Clone + Eq + Debug
type Signature: Eq + Clone
type In: Stream<Item = SignedMessage<H, N, Self::Signature, Self::Id>, Error = Self::Error>
type Out: Sink<SinkItem = Message<H, N>, SinkError = Self::Error>
type Error: From<Error> + Error
Required methods
fn round_data(
&self,
round: u64
) -> RoundData<Self::Id, Self::Timer, Self::In, Self::Out>
&self,
round: u64
) -> RoundData<Self::Id, Self::Timer, Self::In, Self::Out>
Produce data necessary to start a round of voting.
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
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>
&self,
round: u64,
propose: PrimaryPropose<H, N>
) -> Result<(), Self::Error>
Note that we've done a primary proposal in the given round.
fn prevoted(
&self,
round: u64,
prevote: Prevote<H, N>
) -> Result<(), Self::Error>
&self,
round: u64,
prevote: Prevote<H, N>
) -> Result<(), Self::Error>
Note that we have prevoted in the given round.
fn precommitted(
&self,
round: u64,
precommit: Precommit<H, N>
) -> Result<(), Self::Error>
&self,
round: u64,
precommit: Precommit<H, N>
) -> Result<(), Self::Error>
Note that we have precommitted in the given round.
fn completed(
&self,
round: u64,
state: RoundState<H, N>,
base: (H, N),
votes: Vec<SignedMessage<H, N, Self::Signature, Self::Id>>
) -> Result<(), Self::Error>
&self,
round: u64,
state: RoundState<H, N>,
base: (H, N),
votes: Vec<SignedMessage<H, N, Self::Signature, Self::Id>>
) -> Result<(), Self::Error>
Note that a round was completed. This is called when a round has been voted in. Should return an error when something fatal occurs.
fn finalize_block(
&self,
hash: H,
number: N,
round: u64,
commit: Commit<H, N, Self::Signature, Self::Id>
) -> Result<(), Self::Error>
&self,
hash: H,
number: N,
round: u64,
commit: Commit<H, N, Self::Signature, Self::Id>
) -> Result<(), Self::Error>
Called when a block should be finalized.
fn prevote_equivocation(
&self,
round: u64,
equivocation: Equivocation<Self::Id, Prevote<H, N>, Self::Signature>
)
&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>
)
&self,
round: u64,
equivocation: Equivocation<Self::Id, Precommit<H, N>, Self::Signature>
)