reth_primitives_traits/block/
mod.rspub mod body;
pub mod header;
use alloc::fmt;
use alloy_consensus::Header;
use alloy_rlp::{Decodable, Encodable};
use crate::{
BlockBody, BlockHeader, FullBlockBody, FullBlockHeader, InMemorySize, MaybeSerde,
SignedTransaction,
};
pub trait FullBlock:
Block<Header: FullBlockHeader, Body: FullBlockBody> + alloy_rlp::Encodable + alloy_rlp::Decodable
{
}
impl<T> FullBlock for T where
T: Block<Header: FullBlockHeader, Body: FullBlockBody>
+ alloy_rlp::Encodable
+ alloy_rlp::Decodable
{
}
pub type BlockTx<B> = <<B as Block>::Body as BlockBody>::Transaction;
pub trait Block:
Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ PartialEq
+ Eq
+ InMemorySize
+ MaybeSerde
+ Encodable
+ Decodable
{
type Header: BlockHeader;
type Body: BlockBody<OmmerHeader = Self::Header>;
fn new(header: Self::Header, body: Self::Body) -> Self;
fn header(&self) -> &Self::Header;
fn body(&self) -> &Self::Body;
fn split(self) -> (Self::Header, Self::Body);
}
impl<T> Block for alloy_consensus::Block<T>
where
T: SignedTransaction,
{
type Header = Header;
type Body = alloy_consensus::BlockBody<T>;
fn new(header: Self::Header, body: Self::Body) -> Self {
Self { header, body }
}
fn header(&self) -> &Self::Header {
&self.header
}
fn body(&self) -> &Self::Body {
&self.body
}
fn split(self) -> (Self::Header, Self::Body) {
(self.header, self.body)
}
}