pub trait BlockPayload<TYPES>: Serialize + Clone + Debug + Display + Hash + PartialEq + Eq + Send + Sync + DeserializeOwned + EncodeBytes
where TYPES: NodeType,
{ type Error: Error + Debug + Send + Sync + Serialize + DeserializeOwned; type Instance: InstanceState; type Transaction: Transaction + Serialize + DeserializeOwned; type ValidatedState: ValidatedState<TYPES>; type Metadata: Clone + Debug + DeserializeOwned + Eq + Hash + Send + Sync + Serialize + EncodeBytes; // Required methods fn from_transactions<'life0, 'life1, 'async_trait>( transactions: impl IntoIterator<Item = Self::Transaction> + Send + 'async_trait, validated_state: &'life0 Self::ValidatedState, instance_state: &'life1 Self::Instance ) -> Pin<Box<dyn Future<Output = Result<(Self, Self::Metadata), Self::Error>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn from_bytes( encoded_transactions: &[u8], metadata: &Self::Metadata ) -> Self; fn empty() -> (Self, Self::Metadata); fn builder_commitment(&self, metadata: &Self::Metadata) -> BuilderCommitment; fn transactions<'a>( &'a self, metadata: &'a Self::Metadata ) -> impl Iterator<Item = Self::Transaction> + 'a; // Provided methods fn transaction_commitments( &self, metadata: &Self::Metadata ) -> Vec<Commitment<Self::Transaction>> { ... } fn num_transactions(&self, metadata: &Self::Metadata) -> usize { ... } }
Expand description

Abstraction over the full contents of a block

This trait encapsulates the behaviors that the transactions of a block must have in order to be used by consensus

  • Must have a predefined error type (BlockPayload::Error)
  • Must have a transaction type that can be compared for equality, serialized and serialized, sent between threads, and can have a hash produced of it
  • Must be hashable

Required Associated Types§

type Error: Error + Debug + Send + Sync + Serialize + DeserializeOwned

The error type for this type of block

type Instance: InstanceState

The type of the instance-level state this state is associated with

type Transaction: Transaction + Serialize + DeserializeOwned

The type of the transitions we are applying

type ValidatedState: ValidatedState<TYPES>

Validated State

type Metadata: Clone + Debug + DeserializeOwned + Eq + Hash + Send + Sync + Serialize + EncodeBytes

Data created during block building which feeds into the block header

Required Methods§

fn from_transactions<'life0, 'life1, 'async_trait>( transactions: impl IntoIterator<Item = Self::Transaction> + Send + 'async_trait, validated_state: &'life0 Self::ValidatedState, instance_state: &'life1 Self::Instance ) -> Pin<Box<dyn Future<Output = Result<(Self, Self::Metadata), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Build a payload and associated metadata with the transactions. This function is asynchronous because it may need to request updated state from the peers via GET requests.

§Errors

If the transaction length conversion fails.

fn from_bytes(encoded_transactions: &[u8], metadata: &Self::Metadata) -> Self

Build a payload with the encoded transaction bytes, metadata, and the associated number of VID storage nodes

fn empty() -> (Self, Self::Metadata)

Build the payload and metadata for genesis/null block.

fn builder_commitment(&self, metadata: &Self::Metadata) -> BuilderCommitment

Generate commitment that builders use to sign block options.

fn transactions<'a>( &'a self, metadata: &'a Self::Metadata ) -> impl Iterator<Item = Self::Transaction> + 'a

Get the transactions in the payload.

Provided Methods§

fn transaction_commitments( &self, metadata: &Self::Metadata ) -> Vec<Commitment<Self::Transaction>>

List of transaction commitments.

fn num_transactions(&self, metadata: &Self::Metadata) -> usize

Number of transactions in the block.

Object Safety§

This trait is not object safe.

Implementors§