feat: make downloaders and clients generic over block parts (#12469)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Arsenii Kulikov
2024-11-12 19:13:21 +04:00
committed by GitHub
parent 3a337cd7d4
commit aece53ae88
60 changed files with 631 additions and 409 deletions

View File

@ -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
{
}

View File

@ -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)
}
}

View File

@ -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()
}
}