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:
@ -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