Trait reef::traits::Block

source ·
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

A block of transactions.

From the point of view of this abstraction, a Block is just a list of transactions, although the implementation of Block may contain additional metadata.

Required Associated Types§

source

type Transaction: Transaction

Transactions in this block.

source

type Error: ValidationError

Errors that can occur when validation this block.

Required Methods§

source

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.

source

fn txns(&self) -> Vec<Self::Transaction>

The transactions in this block.

Provided Methods§

source

fn len(&self) -> usize

The number of transactions in this block.

source

fn is_empty(&self) -> bool

Whether there are no transactions in this block.

Implementors§

source§

impl Block for Block

§

type Transaction = TransactionNote

§

type Error = ValidationError