Skip to content

Commit

Permalink
fix: backoff before retrieving receipts (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhani-cw authored and renancloudwalk committed May 24, 2024
1 parent 5a6d9e1 commit ce347ba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bin/importer_online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const PARALLEL_RECEIPTS: usize = 100;
/// Timeout for new newHeads event before fallback to polling.
const TIMEOUT_NEW_HEADS: Duration = Duration::from_millis(2000);

/// Time to wait before we starting retrieving receipts because they are not immediatly available after the block is retrieved.
const BACKOFF_RECEIPTS: Duration = Duration::from_millis(10);

// -----------------------------------------------------------------------------
// Execution
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -285,6 +288,9 @@ async fn fetch_block_and_receipts(chain: Arc<BlockchainClient>, number: BlockNum
// fetch block
let block = fetch_block(Arc::clone(&chain), number).await;

// wait some time until receipts are available
let _ = tokio::time::sleep(BACKOFF_RECEIPTS).await;

// fetch receipts in parallel
let mut receipts_tasks = Vec::with_capacity(block.transactions.len());
for hash in block.transactions.iter().map(|tx| tx.hash()) {
Expand Down

0 comments on commit ce347ba

Please sign in to comment.