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§
Required Methods§
Sourcefn genesis(&mut self) -> impl Future<Output = Self::Digest> + Send
fn genesis(&mut self) -> 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.
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.