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§
Sourcetype Block: Block<Digest = <Self::ApplicationBlock as Digestible>::Digest> + Into<Self::StoredBlock> + Clone
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.
Sourcetype ApplicationBlock: Block + Clone
type ApplicationBlock: Block + Clone
The application block type.
Sourcetype StoredBlock: Block<Digest = <Self::Block as Digestible>::Digest> + Into<Self::Block> + Clone + Codec<Cfg = <Self::Block as Read>::Cfg>
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.
Sourcetype Commitment: Digest
type Commitment: Digest
The Digest type used by consensus.
Required Methods§
Sourcefn commitment(block: &Self::Block) -> Self::Commitment
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().
Sourcefn commitment_to_inner(
commitment: Self::Commitment,
) -> <Self::Block as Digestible>::Digest
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.
Sourcefn parent_commitment(block: &Self::Block) -> Self::Commitment
fn parent_commitment(block: &Self::Block) -> Self::Commitment
Returns the parent commitment referenced by block.
Sourcefn into_inner(block: Self::Block) -> Self::ApplicationBlock
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.