Trait hotshot::traits::BlockPayload
pub trait BlockPayload<TYPES>: Serialize + Clone + Debug + Display + Hash + PartialEq + Eq + Send + Sync + DeserializeOwned + EncodeByteswhere
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
type Error: Error + Debug + Send + Sync + Serialize + DeserializeOwned
The error type for this type of block
type Instance: InstanceState
type Instance: InstanceState
The type of the instance-level state this state is associated with
type Transaction: Transaction + Serialize + DeserializeOwned
type Transaction: Transaction + Serialize + DeserializeOwned
The type of the transitions we are applying
type ValidatedState: ValidatedState<TYPES>
type ValidatedState: ValidatedState<TYPES>
Validated State
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_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
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 builder_commitment(&self, metadata: &Self::Metadata) -> BuilderCommitment
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
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>>
fn transaction_commitments( &self, metadata: &Self::Metadata ) -> Vec<Commitment<Self::Transaction>>
List of transaction commitments.
fn num_transactions(&self, metadata: &Self::Metadata) -> usize
fn num_transactions(&self, metadata: &Self::Metadata) -> usize
Number of transactions in the block.