Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: backoff before retrieving receipts #926

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading