Skip to main content

Variant

Trait Variant 

Source
pub trait Variant:
    Clone
    + Send
    + Sync
    + 'static {
    type Block: Block<Digest = <Self::ApplicationBlock as Digestible>::Digest> + Into<Self::StoredBlock> + Clone;
    type ApplicationBlock: Block + Clone;
    type StoredBlock: Block<Digest = <Self::Block as Digestible>::Digest> + Into<Self::Block> + Clone + Codec<Cfg = <Self::Block as Read>::Cfg>;
    type Commitment: Digest;

    // Required methods
    fn commitment(block: &Self::Block) -> Self::Commitment;
    fn commitment_to_inner(
        commitment: Self::Commitment,
    ) -> <Self::Block as Digestible>::Digest;
    fn parent_commitment(block: &Self::Block) -> Self::Commitment;
    fn into_inner(block: Self::Block) -> Self::ApplicationBlock;
}
Expand description

A marker trait describing the types used by a variant of Marshal.

Required Associated Types§

Source

type Block: Block<Digest = <Self::ApplicationBlock as Digestible>::Digest> + Into<Self::StoredBlock> + Clone

The working block type of marshal, supporting the consensus commitment.

Must be convertible to StoredBlock via Into for archival.

Source

type ApplicationBlock: Block + Clone

The application block type.

Source

type StoredBlock: Block<Digest = <Self::Block as Digestible>::Digest> + Into<Self::Block> + Clone + Codec<Cfg = <Self::Block as Read>::Cfg>

The type of block stored in the archive.

Must be convertible back to the working block type via Into.

Source

type Commitment: Digest

The Digest type used by consensus.

Required Methods§

Source

fn commitment(block: &Self::Block) -> Self::Commitment

Computes the consensus commitment for a block.

The commitment is what validators sign over during consensus.

Together with Variant::commitment_to_inner, implementations must satisfy: commitment_to_inner(commitment(block)) == block.digest().

Source

fn commitment_to_inner( commitment: Self::Commitment, ) -> <Self::Block as Digestible>::Digest

Extracts the block digest from a consensus commitment.

For blocks/certificates accepted by marshal in this variant instance, the digest must uniquely determine the commitment. In other words, there should not be two accepted commitments with the same inner digest.

Source

fn parent_commitment(block: &Self::Block) -> Self::Commitment

Returns the parent commitment referenced by block.

Source

fn into_inner(block: Self::Block) -> Self::ApplicationBlock

Converts a working block to an application block.

This conversion cannot use Into due to orphan rules when Block wraps ApplicationBlock (e.g., CodedBlock<B, C, H> -> B).

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§