Skip to content

Commit

Permalink
Add sleep in builder loop (#2983)
Browse files Browse the repository at this point in the history
* add sleep

* change where sleep is

* better sleep
  • Loading branch information
rob-maron authored Apr 18, 2024
1 parent 0217666 commit 4bbd71c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/task-impls/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl<

let last_leaf = self.consensus.read().await.get_decided_leaf();
let mut latest_block: Option<BuilderResponses<TYPES>> = 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
Expand All @@ -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) = <<TYPES as NodeType>::SignatureKey as SignatureKey>::sign(
&self.private_key,
last_leaf.get_block_header().builder_commitment().as_ref(),
Expand Down Expand Up @@ -325,7 +333,6 @@ impl<
if num_txns >= self.api.min_transactions() {
return latest_block;
}
async_sleep(Duration::from_millis(100)).await;
}
latest_block
}
Expand Down

0 comments on commit 4bbd71c

Please sign in to comment.