Skip to content

Commit

Permalink
Don't request finalized block more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
Lohann committed Sep 2, 2024
1 parent 20e38ec commit a4a0bb0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions chains/ethereum/server/src/block_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ where
BlockFinalityStrategy::Confirmations(confirmations) => {
let latest_block_number = self.latest_block().await?.header().number();
let best_block_number = latest_block_number.saturating_sub(confirmations);
// If the best block number is the same, simply refresh the cache timestamp.
if best_block_number == guard.0.header().number() {
*guard = (guard.0.clone(), Instant::now());
return Ok(guard.0.clone());
}
AtBlock::At(BlockIdentifier::Number(best_block_number))
},
};
Expand Down

0 comments on commit a4a0bb0

Please sign in to comment.