pub trait Automaton:
Clone
+ Send
+ 'static {
type Context;
type Digest: Digest;
// Required methods
fn genesis(
&mut self,
epoch: Epoch,
) -> 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§
Required Methods§
Sourcefn genesis(&mut self, epoch: Epoch) -> impl Future<Output = Self::Digest> + Send
fn genesis(&mut self, epoch: Epoch) -> impl Future<Output = Self::Digest> + Send
Payload used to initialize the consensus engine.
Sourcefn propose(
&mut self,
context: Self::Context,
) -> impl Future<Output = Receiver<Self::Digest>> + Send
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.
Sourcefn verify(
&mut self,
context: Self::Context,
payload: Self::Digest,
) -> impl Future<Output = Receiver<bool>> + Send
fn verify( &mut self, context: Self::Context, payload: Self::Digest, ) -> impl Future<Output = Receiver<bool>> + Send
Verify the payload is valid.
This request is single-shot for the given (context, payload). Once the returned
channel resolves or closes, consensus treats verification as concluded and will not
retry the same request.
Implementations should therefore keep the request pending while the verdict may still
change. Return false only when the payload is permanently invalid for this context.
For example, temporary conditions such as time skew, missing dependencies, or data
that may arrive later should not conclude verification with false.
Closing the channel is also terminal for this request and should be reserved for cases where verification cannot ever produce a verdict anymore (for example, shutdown), not for temporary inability to decide.
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.