From 4bbd71c6354705a37a9a8c9821da301e7a70a342 Mon Sep 17 00:00:00 2001 From: rob-maron <132852777+rob-maron@users.noreply.github.com> Date: Wed, 17 Apr 2024 20:27:18 -0400 Subject: [PATCH] Add sleep in builder loop (#2983) * add sleep * change where sleep is * better sleep --- crates/task-impls/src/transactions.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/task-impls/src/transactions.rs b/crates/task-impls/src/transactions.rs index c709df9995..db2129c302 100644 --- a/crates/task-impls/src/transactions.rs +++ b/crates/task-impls/src/transactions.rs @@ -170,6 +170,7 @@ impl< let last_leaf = self.consensus.read().await.get_decided_leaf(); let mut latest_block: Option> = None; + let mut first_iteration = true; while task_start_time.elapsed() < self.api.propose_max_round_time() && latest_block.as_ref().map_or(true, |builder_response| { builder_response @@ -179,6 +180,13 @@ impl< < self.api.min_transactions() }) { + // Sleep if this isn't the first iteration + if first_iteration { + first_iteration = false; + } else { + async_sleep(Duration::from_millis(100)).await; + } + let Ok(request_signature) = <::SignatureKey as SignatureKey>::sign( &self.private_key, last_leaf.get_block_header().builder_commitment().as_ref(), @@ -325,7 +333,6 @@ impl< if num_txns >= self.api.min_transactions() { return latest_block; } - async_sleep(Duration::from_millis(100)).await; } latest_block }