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

This commit is contained in:
Michael Vines 2019-09-27 10:36:38 -07:00 committed by GitHub
parent cc05019bbb
commit 16e3ba86d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -425,9 +425,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));
@ -439,13 +439,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
),
))