use alloy_primitives::{BlockNumber, U256};
use reth_primitives::{SealedBlock, SealedHeader};
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum BlockResponse {
Full(SealedBlock),
Empty(SealedHeader),
}
impl BlockResponse {
pub const fn header(&self) -> &SealedHeader {
match self {
Self::Full(block) => &block.header,
Self::Empty(header) => header,
}
}
#[inline]
pub fn size(&self) -> usize {
match self {
Self::Full(block) => SealedBlock::size(block),
Self::Empty(header) => SealedHeader::size(header),
}
}
pub fn block_number(&self) -> BlockNumber {
self.header().number
}
pub fn difficulty(&self) -> U256 {
match self {
Self::Full(block) => block.difficulty,
Self::Empty(header) => header.difficulty,
}
}
}