From b5d714eec77f6a054a22f6f835e624254383b29c Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 27 Feb 2019 10:37:38 -0800 Subject: [PATCH] Derive retry timeout from slot duration --- wallet/src/wallet.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wallet/src/wallet.rs b/wallet/src/wallet.rs index 3343ccd5d0..345acfa1f6 100644 --- a/wallet/src/wallet.rs +++ b/wallet/src/wallet.rs @@ -22,6 +22,7 @@ use solana_sdk::loader_transaction::LoaderTransaction; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; use solana_sdk::system_transaction::SystemTransaction; +use solana_sdk::timing::{DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND}; use solana_sdk::transaction::Transaction; use std::fs::File; use std::io::Read; @@ -775,7 +776,10 @@ fn send_and_confirm_tx( break status; } if cfg!(not(test)) { - sleep(Duration::from_millis(500)); + // Retry ~twice during a slot + sleep(Duration::from_millis( + 500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND as u64, + )); } }; match status { @@ -823,7 +827,10 @@ fn resign_tx( ))?; } next_last_id_retries -= 1; - sleep(Duration::from_secs(1)); + // Retry ~twice during a slot + sleep(Duration::from_millis( + 500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND as u64, + )); }; tx.sign(&[signer_key], last_id);