pub struct DigL2Block {
pub header: L2BlockHeader,
pub body: L2BlockBody,
}Expand description
Full L2 block containing a header and a body.
Fields§
§header: L2BlockHeader§body: L2BlockBodyImplementations§
Source§impl DigL2Block
impl DigL2Block
Sourcepub fn calculate_root(&self) -> Hash32
pub fn calculate_root(&self) -> Hash32
Calculates the BLOCK_ROOT by composing the HEADER_ROOT and BODY_ROOT.
Sourcepub fn new(
header: L2BlockHeader,
body: L2BlockBody,
expected_version: Option<u32>,
) -> Result<Self, BlockError>
pub fn new( header: L2BlockHeader, body: L2BlockBody, expected_version: Option<u32>, ) -> Result<Self, BlockError>
Validates consistency between header and body and returns a block if valid.
Checks:
data_countandemissions_countmatch body lengths.header.body_rootequalsbody.calculate_root().- If
expected_versionis provided, header version matches it.
Sourcepub fn build(args: &BuildL2BlockArgs<'_>) -> Result<Self, BlockError>
pub fn build(args: &BuildL2BlockArgs<'_>) -> Result<Self, BlockError>
Build a block from raw inputs, constructing required consensus emissions and composing header/body deterministically.
Steps:
- Validates the provided
ConsensusEmissionConfigagainst the attester list. - Uses
BUILD_CONSENSUS_EMISSIONSto create mandatory emissions (proposer + attesters). - Appends any
extra_emissionsprovided by the caller. - Assembles the body from
dataand all emissions, computesbody_root. - Fills header counts and
body_root, leaving other header fields as provided.
Trait Implementations§
Source§impl Clone for DigL2Block
impl Clone for DigL2Block
Source§fn clone(&self) -> DigL2Block
fn clone(&self) -> DigL2Block
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 moreSource§impl Debug for DigL2Block
impl Debug for DigL2Block
Source§impl<'de> Deserialize<'de> for DigL2Block
impl<'de> Deserialize<'de> for DigL2Block
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for DigL2Block
impl PartialEq for DigL2Block
Source§impl Serialize for DigL2Block
impl Serialize for DigL2Block
impl Eq for DigL2Block
impl StructuralPartialEq for DigL2Block
Auto Trait Implementations§
impl Freeze for DigL2Block
impl RefUnwindSafe for DigL2Block
impl Send for DigL2Block
impl Sync for DigL2Block
impl Unpin for DigL2Block
impl UnwindSafe for DigL2Block
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