mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
chore(consensus): Remove associated type Consensus::Error (#20843)
Co-authored-by: Josh_dfG <126518346+JoshdfG@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,7 @@ use alloy_primitives::BlockNumber;
|
||||
use futures::Stream;
|
||||
use futures_util::StreamExt;
|
||||
use reth_config::BodiesConfig;
|
||||
use reth_consensus::{Consensus, ConsensusError};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_network_p2p::{
|
||||
bodies::{
|
||||
client::BodiesClient,
|
||||
@@ -41,7 +41,7 @@ pub struct BodiesDownloader<
|
||||
/// The bodies client
|
||||
client: Arc<C>,
|
||||
/// The consensus client
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
/// The database handle
|
||||
provider: Provider,
|
||||
/// The maximum number of non-empty blocks per one request
|
||||
@@ -577,7 +577,7 @@ impl BodiesDownloaderBuilder {
|
||||
pub fn build<B, C, Provider>(
|
||||
self,
|
||||
client: C,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
provider: Provider,
|
||||
) -> BodiesDownloader<B, C, Provider>
|
||||
where
|
||||
|
||||
@@ -4,7 +4,7 @@ use alloy_consensus::BlockHeader;
|
||||
use alloy_primitives::BlockNumber;
|
||||
use futures::{stream::FuturesUnordered, Stream};
|
||||
use futures_util::StreamExt;
|
||||
use reth_consensus::{Consensus, ConsensusError};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_network_p2p::{
|
||||
bodies::{client::BodiesClient, response::BlockResponse},
|
||||
error::DownloadResult,
|
||||
@@ -58,7 +58,7 @@ where
|
||||
pub(crate) fn push_new_request(
|
||||
&mut self,
|
||||
client: Arc<C>,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
request: Vec<SealedHeader<B::Header>>,
|
||||
) {
|
||||
// Set last max requested block number
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::metrics::{BodyDownloaderMetrics, ResponseMetrics};
|
||||
use alloy_consensus::BlockHeader;
|
||||
use alloy_primitives::B256;
|
||||
use futures::{Future, FutureExt};
|
||||
use reth_consensus::{Consensus, ConsensusError};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_network_p2p::{
|
||||
bodies::{client::BodiesClient, response::BlockResponse},
|
||||
error::{DownloadError, DownloadResult},
|
||||
@@ -38,7 +38,7 @@ use std::{
|
||||
/// and eventually disconnected.
|
||||
pub(crate) struct BodiesRequestFuture<B: Block, C: BodiesClient<Body = B::Body>> {
|
||||
client: Arc<C>,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
metrics: BodyDownloaderMetrics,
|
||||
/// Metrics for individual responses. This can be used to observe how the size (in bytes) of
|
||||
/// responses change while bodies are being downloaded.
|
||||
@@ -60,7 +60,7 @@ where
|
||||
/// Returns an empty future. Use [`BodiesRequestFuture::with_headers`] to set the request.
|
||||
pub(crate) fn new(
|
||||
client: Arc<C>,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
metrics: BodyDownloaderMetrics,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -42,7 +42,7 @@ impl<B: Block + 'static> TaskDownloader<B> {
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use reth_consensus::{Consensus, ConsensusError};
|
||||
/// use reth_consensus::Consensus;
|
||||
/// use reth_downloaders::bodies::{bodies::BodiesDownloaderBuilder, task::TaskDownloader};
|
||||
/// use reth_network_p2p::bodies::client::BodiesClient;
|
||||
/// use reth_primitives_traits::{Block, InMemorySize};
|
||||
@@ -55,7 +55,7 @@ impl<B: Block + 'static> TaskDownloader<B> {
|
||||
/// Provider: HeaderProvider<Header = B::Header> + Unpin + 'static,
|
||||
/// >(
|
||||
/// client: Arc<C>,
|
||||
/// consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
/// consensus: Arc<dyn Consensus<B>>,
|
||||
/// provider: Provider,
|
||||
/// ) {
|
||||
/// let downloader =
|
||||
|
||||
@@ -86,7 +86,7 @@ impl<B: FullBlock> FileClient<B> {
|
||||
/// Create a new file client from a file path.
|
||||
pub async fn new<P: AsRef<Path>>(
|
||||
path: P,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
) -> Result<Self, FileClientError> {
|
||||
let file = File::open(path).await?;
|
||||
Self::from_file(file, consensus).await
|
||||
@@ -95,7 +95,7 @@ impl<B: FullBlock> FileClient<B> {
|
||||
/// Initialize the [`FileClient`] with a file directly.
|
||||
pub(crate) async fn from_file(
|
||||
mut file: File,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
) -> Result<Self, FileClientError> {
|
||||
// get file len from metadata before reading
|
||||
let metadata = file.metadata().await?;
|
||||
@@ -200,7 +200,7 @@ impl<B: FullBlock> FileClient<B> {
|
||||
}
|
||||
|
||||
struct FileClientBuilder<B: Block> {
|
||||
pub consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
pub consensus: Arc<dyn Consensus<B>>,
|
||||
pub parent_header: Option<SealedHeader<B::Header>>,
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ impl ChunkedFileReader {
|
||||
/// are available before processing. For plain files, it uses the original chunking logic.
|
||||
pub async fn next_chunk<B: FullBlock>(
|
||||
&mut self,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
parent_header: Option<SealedHeader<B::Header>>,
|
||||
) -> Result<Option<FileClient<B>>, FileClientError> {
|
||||
let Some(chunk_len) = self.read_next_chunk().await? else { return Ok(None) };
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::{
|
||||
use alloy_consensus::BlockHeader;
|
||||
use alloy_primitives::{Sealable, B256};
|
||||
use core::marker::PhantomData;
|
||||
use reth_consensus::{Consensus, ConsensusError};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_eth_wire_types::{EthNetworkPrimitives, HeadersDirection, NetworkPrimitives};
|
||||
use reth_network_peers::{PeerId, WithPeerId};
|
||||
use reth_primitives_traits::{SealedBlock, SealedHeader};
|
||||
@@ -34,7 +34,7 @@ where
|
||||
Client: BlockClient,
|
||||
{
|
||||
client: Client,
|
||||
consensus: Arc<dyn Consensus<Client::Block, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<Client::Block>>,
|
||||
}
|
||||
|
||||
impl<Client> FullBlockClient<Client>
|
||||
@@ -42,10 +42,7 @@ where
|
||||
Client: BlockClient,
|
||||
{
|
||||
/// Creates a new instance of `FullBlockClient`.
|
||||
pub fn new(
|
||||
client: Client,
|
||||
consensus: Arc<dyn Consensus<Client::Block, Error = ConsensusError>>,
|
||||
) -> Self {
|
||||
pub fn new(client: Client, consensus: Arc<dyn Consensus<Client::Block>>) -> Self {
|
||||
Self { client, consensus }
|
||||
}
|
||||
|
||||
@@ -122,7 +119,7 @@ where
|
||||
Client: BlockClient,
|
||||
{
|
||||
client: Client,
|
||||
consensus: Arc<dyn Consensus<Client::Block, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<Client::Block>>,
|
||||
hash: B256,
|
||||
request: FullBlockRequest<Client>,
|
||||
header: Option<SealedHeader<Client::Header>>,
|
||||
@@ -334,7 +331,7 @@ where
|
||||
/// The client used to fetch headers and bodies.
|
||||
client: Client,
|
||||
/// The consensus instance used to validate the blocks.
|
||||
consensus: Arc<dyn Consensus<Client::Block, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<Client::Block>>,
|
||||
/// The block hash to start fetching from (inclusive).
|
||||
start_hash: B256,
|
||||
/// How many blocks to fetch: `len([start_hash, ..]) == count`
|
||||
|
||||
Reference in New Issue
Block a user