mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make OrderedSealedBlock generic over header and body types (#12830)
This commit is contained in:
@ -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
|
||||
|
||||
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user