From 3713bb32b57e15ee9ce02cc4c1eee8c357feab4c Mon Sep 17 00:00:00 2001 From: Kevin Ji <1146876+kevinji@users.noreply.github.com> Date: Tue, 28 Mar 2023 20:48:52 -0700 Subject: [PATCH] tpu-client: Fix counter for expired blockhash retries (#30360) tpu-client: Fix counter for expired blockhash retries The original counter would expire after saying "1 retry left", which was misleading. We can safely change the comparison to >= 0 as our counter is an i32. --- tpu-client/src/nonblocking/tpu_client.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tpu-client/src/nonblocking/tpu_client.rs b/tpu-client/src/nonblocking/tpu_client.rs index a94f954e3..8214dfa6f 100644 --- a/tpu-client/src/nonblocking/tpu_client.rs +++ b/tpu-client/src/nonblocking/tpu_client.rs @@ -442,7 +442,6 @@ where messages: &[Message], signers: &T, ) -> Result>> { - let mut expired_blockhash_retries = 5; let progress_bar = spinner::new_progress_bar(); progress_bar.set_message("Setting up..."); @@ -455,7 +454,7 @@ where let mut transaction_errors = vec![None; transactions.len()]; let mut confirmed_transactions = 0; let mut block_height = self.rpc_client.get_block_height().await?; - while expired_blockhash_retries > 0 { + for expired_blockhash_retries in (0..5).rev() { let (blockhash, last_valid_block_height) = self .rpc_client .get_latest_blockhash_with_commitment(self.rpc_client.commitment()) @@ -555,7 +554,6 @@ where progress_bar.println(format!( "Blockhash expired. {expired_blockhash_retries} retries remaining" )); - expired_blockhash_retries -= 1; } Err(TpuSenderError::Custom("Max retries exceeded".into())) }