Skip to main content

Application

Trait Application 

Source
pub trait Application<E>:
    Clone
    + Send
    + 'static
where E: Rng + Spawner + Metrics + Clock,
{ type SigningScheme: Scheme; type Context: Epochable; type Block: Block; // Required methods fn propose( &mut self, context: (E, Self::Context), ancestry: impl Ancestry<Self::Block>, ) -> impl Future<Output = Option<Self::Block>> + Send; fn verify( &mut self, context: (E, Self::Context), ancestry: impl Ancestry<Self::Block>, ) -> impl Future<Output = bool> + Send; }
Expand description

Application is a minimal interface for standard implementations that operate over a stream of epoched blocks.

Required Associated Types§

Source

type SigningScheme: Scheme

The signing scheme used by the application.

Source

type Context: Epochable

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 Block: Block

The block type produced by the application’s builder.

Required Methods§

Source

fn propose( &mut self, context: (E, Self::Context), ancestry: impl Ancestry<Self::Block>, ) -> impl Future<Output = Option<Self::Block>> + Send

Build a new block on top of the provided parent ancestry. If the build job fails, or the proposer’s slot should be skipped, the implementor should return None.

This future may be cancelled before it completes. Implementations must be cancellation-safe.

Source

fn verify( &mut self, context: (E, Self::Context), ancestry: impl Ancestry<Self::Block>, ) -> impl Future<Output = bool> + Send

Verify a block produced by the application’s proposer, relative to its ancestry.

This future should not resolve until the implementation can produce a stable verdict. Return false only when the block is permanently invalid for the supplied context and ancestry. If validity may still change as additional information becomes available, continue waiting instead of returning false.

In other words, to abstain from voting, do not resolve this future yet. Keep it pending until the implementation can either prove the block valid, prove it invalid, or the consensus engine cancels the request. Abstaining is not represented by a special return value.

This future may be cancelled before it completes. Implementations must be cancellation-safe.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§