feat(cli): added header request retry in stages run command (#13816)

This commit is contained in:
Dhruv Agarwal
2025-01-16 21:54:12 +05:30
committed by GitHub
parent 9b68cf88c7
commit a90ecd9057

View File

@ -189,9 +189,15 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + Hardforks + EthereumHardforks>
let fetch_client = Arc::new(network.fetch_client().await?);
// Use `to` as the tip for the stage
let tip: P::BlockHeader = fetch_client
.get_header(BlockHashOrNumber::Number(self.to))
.await?
let tip: P::BlockHeader = loop {
match fetch_client.get_header(BlockHashOrNumber::Number(self.to)).await {
Ok(header) => break header,
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());