Trait Automaton

Source
pub trait Automaton:
    Clone
    + Send
    + 'static {
    type Context;
    type Digest: Digest;

    // Required methods
    fn genesis(&mut self) -> impl Future<Output = Self::Digest> + Send;
    fn propose(
        &mut self,
        context: Self::Context,
    ) -> impl Future<Output = Receiver<Self::Digest>> + Send;
    fn verify(
        &mut self,
        context: Self::Context,
        payload: Self::Digest,
    ) -> impl Future<Output = Receiver<bool>> + Send;
}
Expand description

Automaton is the interface responsible for driving the consensus forward by proposing new payloads and verifying payloads proposed by other participants.

Required Associated Types§

Source

type Context

Context is metadata provided by the consensus engine associated with a given payload.

This often includes things like the proposer, view number, the height, or the epoch.

Source

type Digest: Digest

Hash of an arbitrary payload.

Required Methods§

Source

fn genesis(&mut self) -> impl Future<Output = Self::Digest> + Send

Payload used to initialize the consensus engine.

Source

fn propose( &mut self, context: Self::Context, ) -> impl Future<Output = Receiver<Self::Digest>> + Send

Generate a new payload for the given context.

If it is possible to generate a payload, the Digest should be returned over the provided channel. If it is not possible to generate a payload, the channel can be dropped. If construction takes too long, the consensus engine may drop the provided proposal.

Source

fn verify( &mut self, context: Self::Context, payload: Self::Digest, ) -> impl Future<Output = Receiver<bool>> + Send

Verify the payload is valid.

If it is possible to verify the payload, a boolean should be returned indicating whether the payload is valid. If it is not possible to verify the payload, the channel can be dropped.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§