pub struct ZenithBlock<C: Coder = Alloy2718Coder> { /* private fields */ }Expand description
A Zenith block is just a list of transactions.
Implementations§
Source§impl<C> ZenithBlock<C>where
C: Coder,
impl<C> ZenithBlock<C>where
C: Coder,
Sourcepub const fn new(
header: ZenithHeader,
transactions: Vec<<C as Coder>::Tx>,
) -> Self
pub const fn new( header: ZenithHeader, transactions: Vec<<C as Coder>::Tx>, ) -> Self
Create a new zenith block.
Sourcepub fn from_header_and_data(header: ZenithHeader, buf: impl AsRef<[u8]>) -> Self
pub fn from_header_and_data(header: ZenithHeader, buf: impl AsRef<[u8]>) -> Self
Decode tx data in the block.
This will perform the following steps:
- Attempt to decode the data as an RLP list
- On failure, discard all data, returning an empty tx list
- Attempt to decode each item in the list as a transaction
- On failure, discard the item
- Return a list of succesfully decoded transactions
Sourcepub fn into_parts(self) -> (ZenithHeader, Vec<C::Tx>)
pub fn into_parts(self) -> (ZenithHeader, Vec<C::Tx>)
Break the block into its parts.
Sourcepub fn encoded_txns(&self) -> &[u8] ⓘ
pub fn encoded_txns(&self) -> &[u8] ⓘ
Encode the transactions in the block.
Sourcepub fn block_data_hash(&self) -> B256
pub fn block_data_hash(&self) -> B256
The hash of the encoded transactions.
Sourcepub fn push_transaction(&mut self, tx: C::Tx)
pub fn push_transaction(&mut self, tx: C::Tx)
Push a transaction into the block.
Sourcepub fn transactions(&self) -> &[C::Tx]
pub fn transactions(&self) -> &[C::Tx]
Access to the transactions.
Sourcepub fn transactions_mut(&mut self) -> &mut Vec<C::Tx>
pub fn transactions_mut(&mut self) -> &mut Vec<C::Tx>
Mutable access to the transactions.
Sourcepub fn transactions_iter(&self) -> Iter<'_, C::Tx>
pub fn transactions_iter(&self) -> Iter<'_, C::Tx>
Iterate over the transactions.
Sourcepub fn transactions_iter_mut(&mut self) -> IterMut<'_, C::Tx>
pub fn transactions_iter_mut(&mut self) -> IterMut<'_, C::Tx>
Iterate over mut transactions.
Sourcepub const fn header(&self) -> &ZenithHeader
pub const fn header(&self) -> &ZenithHeader
Access to the header.
Sourcepub fn header_mut(&mut self) -> &mut ZenithHeader
pub fn header_mut(&mut self) -> &mut ZenithHeader
Mutable access to the header.
Sourcepub const fn block_height(&self) -> u64
pub const fn block_height(&self) -> u64
Gets the block height according to the header
Sourcepub const fn reward_address(&self) -> Address
pub const fn reward_address(&self) -> Address
Get the reward address of the block.
Trait Implementations§
Source§impl<C: Clone + Coder> Clone for ZenithBlock<C>
impl<C: Clone + Coder> Clone for ZenithBlock<C>
Source§fn clone(&self) -> ZenithBlock<C>
fn clone(&self) -> ZenithBlock<C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<C: Eq + Coder> Eq for ZenithBlock<C>
impl<C: Coder> StructuralPartialEq for ZenithBlock<C>
Auto Trait Implementations§
impl<C = Alloy2718Coder> !Freeze for ZenithBlock<C>
impl<C> RefUnwindSafe for ZenithBlock<C>
impl<C> Send for ZenithBlock<C>
impl<C> Sync for ZenithBlock<C>
impl<C> Unpin for ZenithBlock<C>
impl<C> UnwindSafe for ZenithBlock<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.