get_new_blockhash() now retries longer (5s instead of 2s) (#6143) (#6150)

automerge
This commit is contained in:
mergify[bot]
2019-09-27 11:27:43 -07:00
committed by Grimes
parent b8f680d1e7
commit 8f27240211

View File

@ -396,9 +396,9 @@ impl RpcClient {
}
pub fn get_new_blockhash(&self, blockhash: &Hash) -> io::Result<(Hash, FeeCalculator)> {
let mut num_retries = 10;
let mut num_retries = 0;
let start = Instant::now();
while num_retries > 0 {
while start.elapsed().as_secs() < 5 {
if let Ok((new_blockhash, fee_calculator)) = self.get_recent_blockhash() {
if new_blockhash != *blockhash {
return Ok((new_blockhash, fee_calculator));
@ -410,13 +410,14 @@ impl RpcClient {
sleep(Duration::from_millis(
500 * DEFAULT_TICKS_PER_SLOT / DEFAULT_TICKS_PER_SECOND,
));
num_retries -= 1;
num_retries += 1;
}
Err(io::Error::new(
io::ErrorKind::Other,
format!(
"Unable to get new blockhash after {}ms, stuck at {}",
"Unable to get new blockhash after {}ms (retried {} times), stuck at {}",
start.elapsed().as_millis(),
num_retries,
blockhash
),
))