Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Derive client retry timeouts from slot duration #2984

Merged
merged 2 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn test_rpc_send_tx() {
"params": [signature],
});

for _ in 0..10 {
for _ in 0..solana_sdk::timing::DEFAULT_TICKS_PER_SLOT {
let mut response = client
.post(&rpc_string)
.header(CONTENT_TYPE, "application/json")
Expand Down
11 changes: 9 additions & 2 deletions wallet/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down