chore(net): move reth_network::BlockDownloaderProvider to reth-network-api (#10003)

This commit is contained in:
Emilia Hane
2024-08-03 15:42:44 +02:00
committed by GitHub
parent c2926de326
commit f3e79df300
7 changed files with 45 additions and 20 deletions

View File

@ -17,6 +17,7 @@ reth-eth-wire.workspace = true
alloy-rpc-types-admin.workspace = true
reth-network-peers.workspace = true
reth-network-types.workspace = true
reth-network-p2p.workspace = true
# ethereum
alloy-primitives.workspace = true
@ -24,6 +25,9 @@ alloy-primitives.workspace = true
# eth
enr = { workspace = true, default-features = false, features = ["rust-secp256k1"] }
# async
futures.workspace = true
# misc
thiserror.workspace = true
serde = { workspace = true, features = ["derive"], optional = true }

View File

@ -0,0 +1,16 @@
//! API related to syncing blocks.
use futures::Future;
use reth_network_p2p::BlockClient;
use tokio::sync::oneshot;
/// Provides client for downloading blocks.
#[auto_impl::auto_impl(&, Arc)]
pub trait BlockDownloaderProvider {
/// Returns a new [`BlockClient`], used for fetching blocks from peers.
///
/// The client is the entrypoint for sending block requests to the network.
fn fetch_client(
&self,
) -> impl Future<Output = Result<impl BlockClient + 'static, oneshot::error::RecvError>> + Send;
}

View File

@ -13,15 +13,19 @@
)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
pub mod downloaders;
/// Network Error
pub mod error;
/// Implementation of network traits for that does nothing.
pub mod noop;
pub use alloy_rpc_types_admin::EthProtocolInfo;
pub use error::NetworkError;
pub use reth_network_p2p::BlockClient;
pub use reth_network_types::{PeerKind, PeersHandle, Reputation, ReputationChangeKind};
pub use downloaders::BlockDownloaderProvider;
pub use error::NetworkError;
use std::{future::Future, net::SocketAddr, sync::Arc, time::Instant};
use reth_eth_wire::{capability::Capabilities, DisconnectReason, EthVersion, Status};