pub trait Block: Clone + Debug + Serialize + DeserializeOwned + Send + Sync {
type Transaction: Transaction;
type Error: ValidationError;
// Required methods
fn add_transaction(
&mut self,
txn: Self::Transaction
) -> Result<(), Self::Error>;
fn txns(&self) -> Vec<Self::Transaction>;
// Provided methods
fn len(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
Required Associated Types§
sourcetype Transaction: Transaction
type Transaction: Transaction
Transactions in this block.
sourcetype Error: ValidationError
type Error: ValidationError
Errors that can occur when validation this block.
Required Methods§
sourcefn add_transaction(&mut self, txn: Self::Transaction) -> Result<(), Self::Error>
fn add_transaction(&mut self, txn: Self::Transaction) -> Result<(), Self::Error>
Add a new Transaction to this block.
Fails if the transaction would make the block inconsistent, for example if the new transaction is incompatible with a transaction already in the block.
sourcefn txns(&self) -> Vec<Self::Transaction>
fn txns(&self) -> Vec<Self::Transaction>
The transactions in this block.