mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: make downloaders and clients generic over block parts (#12469)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -5,6 +5,8 @@ use core::fmt;
|
||||
use alloy_primitives::Sealable;
|
||||
use reth_codecs::Compact;
|
||||
|
||||
use crate::InMemorySize;
|
||||
|
||||
/// Helper trait that unifies all behaviour required by block header to support full node
|
||||
/// operations.
|
||||
pub trait FullBlockHeader: BlockHeader + Compact {}
|
||||
@ -21,12 +23,11 @@ pub trait BlockHeader:
|
||||
+ fmt::Debug
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ serde::Serialize
|
||||
+ for<'de> serde::Deserialize<'de>
|
||||
+ alloy_rlp::Encodable
|
||||
+ alloy_rlp::Decodable
|
||||
+ alloy_consensus::BlockHeader
|
||||
+ Sealable
|
||||
+ InMemorySize
|
||||
{
|
||||
}
|
||||
|
||||
@ -45,5 +46,6 @@ impl<T> BlockHeader for T where
|
||||
+ alloy_rlp::Decodable
|
||||
+ alloy_consensus::BlockHeader
|
||||
+ Sealable
|
||||
+ InMemorySize
|
||||
{
|
||||
}
|
||||
|
||||
@ -56,10 +56,10 @@ impl<H> SealedHeader<H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl SealedHeader {
|
||||
impl<H: alloy_consensus::BlockHeader> SealedHeader<H> {
|
||||
/// Return the number hash tuple.
|
||||
pub fn num_hash(&self) -> BlockNumHash {
|
||||
BlockNumHash::new(self.number, self.hash)
|
||||
BlockNumHash::new(self.number(), self.hash)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,3 +3,9 @@ pub trait InMemorySize {
|
||||
/// Returns a heuristic for the in-memory size of a struct.
|
||||
fn size(&self) -> usize;
|
||||
}
|
||||
|
||||
impl InMemorySize for alloy_consensus::Header {
|
||||
fn size(&self) -> usize {
|
||||
self.size()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user