chore: make OrderedSealedBlock generic over header and body types (#12830)

This commit is contained in:
Tien Nguyen
2024-11-26 20:44:12 +07:00
committed by GitHub
parent 277631092d
commit 2840b6f677
3 changed files with 16 additions and 5 deletions

1
Cargo.lock generated
View File

@ -6489,6 +6489,7 @@ dependencies = [
"reth-payload-primitives",
"reth-payload-validator",
"reth-primitives",
"reth-primitives-traits",
"reth-provider",
"reth-prune",
"reth-prune-types",

View File

@ -17,6 +17,7 @@ reth-blockchain-tree-api.workspace = true
reth-codecs.workspace = true
reth-db-api.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-stages-api.workspace = true
reth-errors.workspace = true
reth-provider.workspace = true

View File

@ -4,13 +4,14 @@ use crate::{
engine::metrics::EngineSyncMetrics, BeaconConsensusEngineEvent,
ConsensusEngineLiveSyncProgress, EthBeaconConsensus,
};
use alloy_consensus::Header;
use alloy_primitives::{BlockNumber, B256};
use futures::FutureExt;
use reth_network_p2p::{
full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient},
EthBlockClient,
};
use reth_primitives::{EthPrimitives, NodePrimitives, SealedBlock};
use reth_primitives::{BlockBody, EthPrimitives, NodePrimitives, SealedBlock};
use reth_provider::providers::ProviderNodeTypes;
use reth_stages_api::{ControlFlow, Pipeline, PipelineError, PipelineTarget, PipelineWithResult};
use reth_tasks::TaskSpawner;
@ -345,17 +346,25 @@ where
/// A wrapper type around [`SealedBlock`] that implements the [Ord] trait by block number.
#[derive(Debug, Clone, PartialEq, Eq)]
struct OrderedSealedBlock(SealedBlock);
struct OrderedSealedBlock<H = Header, B = BlockBody>(SealedBlock<H, B>);
impl PartialOrd for OrderedSealedBlock {
impl<H, B> PartialOrd for OrderedSealedBlock<H, B>
where
H: reth_primitives_traits::BlockHeader + 'static,
B: reth_primitives_traits::BlockBody + 'static,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for OrderedSealedBlock {
impl<H, B> Ord for OrderedSealedBlock<H, B>
where
H: reth_primitives_traits::BlockHeader + 'static,
B: reth_primitives_traits::BlockBody + 'static,
{
fn cmp(&self, other: &Self) -> Ordering {
self.0.number.cmp(&other.0.number)
self.0.number().cmp(&other.0.number())
}
}