From 32aaa5fd063b924609526a4cb6578d88e371b1af Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 27 Feb 2019 13:54:08 -0800 Subject: [PATCH] Derive retry timeout from slot duration --- src/rpc_request.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rpc_request.rs b/src/rpc_request.rs index b53c2d09a5..e547302f6b 100644 --- a/src/rpc_request.rs +++ b/src/rpc_request.rs @@ -1,6 +1,7 @@ use reqwest; use reqwest::header::CONTENT_TYPE; use serde_json::{self, Value}; +use solana_sdk::timing::{DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND}; use std::net::SocketAddr; use std::thread::sleep; use std::time::Duration; @@ -84,8 +85,11 @@ impl RpcClient { Err(e)?; } retries -= 1; - // TODO: Make the caller supply their desired retry frequency? - sleep(Duration::from_millis(500)); + + // Sleep for approximately half a slot + sleep(Duration::from_millis( + 500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND as u64, + )); } } }