mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(reth-network-p2p): Replace HeadersClient + BodiesClient with BlockClient (#10058)
Co-authored-by: Skanda Bhat <bhat.skanda.m@gmail.com>
This commit is contained in:
@ -11,6 +11,7 @@ use reth_network_p2p::{
|
||||
bodies::client::BodiesClient,
|
||||
headers::client::HeadersClient,
|
||||
sync::{NetworkSyncUpdater, SyncState},
|
||||
BlockClient,
|
||||
};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_payload_primitives::{PayloadAttributes, PayloadBuilderAttributes};
|
||||
@ -171,7 +172,7 @@ type PendingForkchoiceUpdate<PayloadAttributes> =
|
||||
pub struct BeaconConsensusEngine<DB, BT, Client, EngineT>
|
||||
where
|
||||
DB: Database,
|
||||
Client: HeadersClient + BodiesClient,
|
||||
Client: BlockClient,
|
||||
BT: BlockchainTreeEngine
|
||||
+ BlockReader
|
||||
+ BlockIdReader
|
||||
|
||||
@ -11,6 +11,7 @@ use reth_network_p2p::{
|
||||
bodies::client::BodiesClient,
|
||||
full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient},
|
||||
headers::client::HeadersClient,
|
||||
BlockClient,
|
||||
};
|
||||
use reth_primitives::{BlockNumber, SealedBlock, B256};
|
||||
use reth_stages_api::{ControlFlow, Pipeline, PipelineError, PipelineTarget, PipelineWithResult};
|
||||
@ -35,7 +36,7 @@ use tracing::trace;
|
||||
pub(crate) struct EngineSyncController<DB, Client>
|
||||
where
|
||||
DB: Database,
|
||||
Client: HeadersClient + BodiesClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
/// A downloader that can download full blocks from the network.
|
||||
full_block_client: FullBlockClient<Client>,
|
||||
|
||||
@ -3,6 +3,7 @@ use crate::{
|
||||
bodies::client::{BodiesClient, SingleBodyRequest},
|
||||
error::PeerRequestResult,
|
||||
headers::client::{HeadersClient, SingleHeaderRequest},
|
||||
BlockClient,
|
||||
};
|
||||
use reth_consensus::{Consensus, ConsensusError};
|
||||
use reth_eth_wire_types::HeadersDirection;
|
||||
@ -41,7 +42,7 @@ impl<Client> FullBlockClient<Client> {
|
||||
|
||||
impl<Client> FullBlockClient<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient + Clone,
|
||||
Client: BlockClient,
|
||||
{
|
||||
/// Returns a future that fetches the [`SealedBlock`] for the given hash.
|
||||
///
|
||||
@ -105,7 +106,7 @@ where
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct FetchFullBlockFuture<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
client: Client,
|
||||
hash: B256,
|
||||
@ -116,7 +117,7 @@ where
|
||||
|
||||
impl<Client> FetchFullBlockFuture<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
/// Returns the hash of the block being requested.
|
||||
pub const fn hash(&self) -> &B256 {
|
||||
@ -168,7 +169,7 @@ where
|
||||
|
||||
impl<Client> Future for FetchFullBlockFuture<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient + Unpin + 'static,
|
||||
Client: BlockClient + 'static,
|
||||
{
|
||||
type Output = SealedBlock;
|
||||
|
||||
@ -229,7 +230,7 @@ where
|
||||
|
||||
impl<Client> Debug for FetchFullBlockFuture<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("FetchFullBlockFuture")
|
||||
@ -242,7 +243,7 @@ where
|
||||
|
||||
struct FullBlockRequest<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
header: Option<SingleHeaderRequest<<Client as HeadersClient>::Output>>,
|
||||
body: Option<SingleBodyRequest<<Client as BodiesClient>::Output>>,
|
||||
@ -250,7 +251,7 @@ where
|
||||
|
||||
impl<Client> FullBlockRequest<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<ResponseResult> {
|
||||
if let Some(fut) = Pin::new(&mut self.header).as_pin_mut() {
|
||||
@ -362,7 +363,7 @@ fn ensure_valid_body_response(
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct FetchFullBlockRangeFuture<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
/// The client used to fetch headers and bodies.
|
||||
client: Client,
|
||||
@ -384,7 +385,7 @@ where
|
||||
|
||||
impl<Client> FetchFullBlockRangeFuture<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
/// Returns the block hashes for the given range, if they are available.
|
||||
pub fn range_block_hashes(&self) -> Option<Vec<B256>> {
|
||||
@ -539,7 +540,7 @@ where
|
||||
|
||||
impl<Client> Future for FetchFullBlockRangeFuture<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient + Unpin + 'static,
|
||||
Client: BlockClient + 'static,
|
||||
{
|
||||
type Output = Vec<SealedBlock>;
|
||||
|
||||
@ -638,7 +639,7 @@ where
|
||||
/// on which future successfully returned.
|
||||
struct FullBlockRangeRequest<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
headers: Option<<Client as HeadersClient>::Output>,
|
||||
bodies: Option<<Client as BodiesClient>::Output>,
|
||||
@ -646,7 +647,7 @@ where
|
||||
|
||||
impl<Client> FullBlockRangeRequest<Client>
|
||||
where
|
||||
Client: BodiesClient + HeadersClient,
|
||||
Client: BlockClient,
|
||||
{
|
||||
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<RangeResponseResult> {
|
||||
if let Some(fut) = Pin::new(&mut self.headers).as_pin_mut() {
|
||||
|
||||
Reference in New Issue
Block a user