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.
This commit is contained in:
Kevin Ji 2023-03-28 20:48:52 -07:00 committed by GitHub
parent 2c842e9932
commit 3713bb32b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -442,7 +442,6 @@ where
messages: &[Message],
signers: &T,
) -> Result<Vec<Option<TransactionError>>> {
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()))
}