Skip to content

Commit

Permalink
feat: add helpers for block (#1816)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 23, 2024
1 parent c6602c2 commit 409af86
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/consensus/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ impl<T, H> Block<T, H> {
pub fn uncle(header: H) -> Self {
Self { header, body: Default::default() }
}

/// Consumes the block and returns the header.
pub fn into_header(self) -> H {
self.header
}

/// Consumes the block and returns the body.
pub fn into_body(self) -> BlockBody<T> {
self.body
}
}

impl<T, H> Default for Block<T, H>
Expand All @@ -44,6 +54,12 @@ where
}
}

impl<T, H> From<Block<T, H>> for BlockBody<T> {
fn from(block: Block<T, H>) -> Self {
block.into_body()
}
}

#[cfg(any(test, feature = "arbitrary"))]
impl<'a, T> arbitrary::Arbitrary<'a> for Block<T>
where
Expand Down

0 comments on commit 409af86

Please sign in to comment.