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

chore: revert the change from yield_now to sleep #964

Merged
merged 2 commits into from
May 31, 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: 2 additions & 4 deletions src/bin/importer_online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use stratus::utils::calculate_tps;
use stratus::GlobalServices;
use stratus::GlobalState;
use tokio::sync::mpsc;
use tokio::task::yield_now;
use tokio::time::sleep;
use tokio::time::timeout;

Expand Down Expand Up @@ -60,9 +61,6 @@ const PARALLEL_RECEIPTS: usize = 100;
/// Timeout awaiting for newHeads event before fallback to polling.
const TIMEOUT_NEW_HEADS: Duration = Duration::from_millis(2000);

/// Interval before we check again if we are behind the external rpc current block number.
const INTERVAL_CATCH_UP: Duration = Duration::from_millis(20);

/// Interval before we starting retrieving receipts because they are not immediately available after the block is retrieved.
const INTERVAL_FETCH_RECEIPTS: Duration = Duration::from_millis(50);

Expand Down Expand Up @@ -295,7 +293,7 @@ async fn start_block_fetcher(
// if we are ahead of current block number, await until we are behind again
let external_rpc_current_block = EXTERNAL_RPC_CURRENT_BLOCK.load(Ordering::Relaxed);
if importer_block_number.as_u64() > external_rpc_current_block {
sleep(INTERVAL_CATCH_UP).await;
yield_now().await;
continue;
}

Expand Down
Loading