Skip to content

Commit

Permalink
feat(cli): added header request retry in stages run command (#13816)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruv-2003 authored Jan 16, 2025
1 parent 9b68cf8 commit a90ecd9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/cli/commands/src/stage/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a90ecd9

Please sign in to comment.