mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: retry empty responses (#13923)
This commit is contained in:
@ -45,8 +45,7 @@ use reth_stages::{
|
|||||||
IndexStorageHistoryStage, MerkleStage, SenderRecoveryStage, StorageHashingStage,
|
IndexStorageHistoryStage, MerkleStage, SenderRecoveryStage, StorageHashingStage,
|
||||||
TransactionLookupStage,
|
TransactionLookupStage,
|
||||||
},
|
},
|
||||||
ExecInput, ExecOutput, ExecutionStageThresholds, Stage, StageError, StageExt, UnwindInput,
|
ExecInput, ExecOutput, ExecutionStageThresholds, Stage, StageExt, UnwindInput, UnwindOutput,
|
||||||
UnwindOutput,
|
|
||||||
};
|
};
|
||||||
use std::{any::Any, net::SocketAddr, sync::Arc, time::Instant};
|
use std::{any::Any, net::SocketAddr, sync::Arc, time::Instant};
|
||||||
use tokio::sync::watch;
|
use tokio::sync::watch;
|
||||||
@ -190,16 +189,18 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + Hardforks + EthereumHardforks>
|
|||||||
|
|
||||||
// Use `to` as the tip for the stage
|
// Use `to` as the tip for the stage
|
||||||
let tip: P::BlockHeader = loop {
|
let tip: P::BlockHeader = loop {
|
||||||
match fetch_client.get_header(BlockHashOrNumber::Number(self.to)).await {
|
match fetch_client.get_header(BlockHashOrNumber::Number(self.to)).await {
|
||||||
Ok(header) => break header,
|
Ok(header) => {
|
||||||
Err(error) if error.is_retryable() => {
|
if let Some(header) = header.into_data() {
|
||||||
warn!(target: "reth::cli", "Error requesting header: {error}. Retrying...")
|
break header
|
||||||
}
|
}
|
||||||
Err(error) => return Err(error.into()),
|
|
||||||
}
|
}
|
||||||
|
Err(error) if error.is_retryable() => {
|
||||||
|
warn!(target: "reth::cli", "Error requesting header: {error}. Retrying...")
|
||||||
|
}
|
||||||
|
Err(error) => return Err(error.into()),
|
||||||
}
|
}
|
||||||
.into_data()
|
};
|
||||||
.ok_or(StageError::MissingSyncGap)?;
|
|
||||||
let (_, rx) = watch::channel(tip.hash_slow());
|
let (_, rx) = watch::channel(tip.hash_slow());
|
||||||
(
|
(
|
||||||
Box::new(HeaderStage::new(
|
Box::new(HeaderStage::new(
|
||||||
|
|||||||
@ -94,6 +94,8 @@ pub trait HeadersClient: DownloadClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A Future that resolves to a single block body.
|
/// A Future that resolves to a single block body.
|
||||||
|
///
|
||||||
|
/// Returns `None` if the peer responded with an empty header response.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[must_use = "futures do nothing unless polled"]
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub struct SingleHeaderRequest<Fut> {
|
pub struct SingleHeaderRequest<Fut> {
|
||||||
|
|||||||
Reference in New Issue
Block a user