Skip to content

Commit e8c3846

Browse files
feat: address v2 test with multiple addresses, add async yields (#1719)
* feat: address v2 test with multiple addresses, add async yields * enhance address creation logic to support multiple addresses * add `tokio::task::yield_now()` in async loops to improve responsiveness * refactor: remove commented debug print statements from test_indexer
1 parent e5f158b commit e8c3846

File tree

9 files changed

+213
-116
lines changed

9 files changed

+213
-116
lines changed

forester-utils/src/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ pub async fn wait_for_indexer<R: RpcConnection, I: Indexer<R>>(
6868
"waiting for indexer to catch up, rpc_slot: {}, indexer_slot: {}",
6969
rpc_slot, indexer_slot
7070
);
71+
72+
tokio::task::yield_now().await;
7173
sleep(std::time::Duration::from_millis(400)).await;
7274
indexer_slot = indexer.get_indexer_slot(rpc).await.map_err(|e| {
7375
error!("failed to get indexer slot from indexer: {:?}", e);

forester/src/epoch_manager.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ impl<R: RpcConnection, I: Indexer<R> + IndexerType<R>> EpochManager<R, I> {
484484
e
485485
);
486486
if attempt < max_retries - 1 {
487+
tokio::task::yield_now().await;
487488
sleep(retry_delay).await;
488489
} else {
489490
if let Err(alert_err) = send_pagerduty_alert(
@@ -1257,6 +1258,7 @@ pub async fn run_service<R: RpcConnection, I: Indexer<R> + IndexerType<R>>(
12571258
retry_count += 1;
12581259
if retry_count < config.retry_config.max_retries {
12591260
debug!("Retrying in {:?}", retry_delay);
1261+
tokio::task::yield_now().await;
12601262
sleep(retry_delay).await;
12611263
retry_delay = std::cmp::min(retry_delay * 2, MAX_RETRY_DELAY);
12621264
} else {

forester/src/slot_tracker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl SlotTracker {
7070
}
7171
Err(e) => error!("Failed to get slot: {:?}", e),
7272
}
73+
tokio::task::yield_now().await;
7374
tokio::time::sleep(self.update_interval).await;
7475
}
7576
}
@@ -105,6 +106,7 @@ pub async fn wait_until_slot_reached<R: RpcConnection>(
105106
current_estimated_slot,
106107
sleep_duration.as_secs_f64()
107108
);
109+
tokio::task::yield_now().await;
108110
sleep(sleep_duration).await;
109111
}
110112

forester/src/smart_transaction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub async fn poll_transaction_confirmation<'a, R: RpcConnection>(
7171
}
7272
}
7373
None => {
74+
tokio::task::yield_now().await;
7475
sleep(interval).await;
7576
}
7677
}

0 commit comments

Comments
 (0)