Skip to content

Commit

Permalink
Rpc Client: Prevent error out on get_num_blocks_since_signature_confi…
Browse files Browse the repository at this point in the history
…rmation (#9792) (#9799)

automerge
  • Loading branch information
mergify[bot] authored Apr 29, 2020
1 parent 6a5d782 commit e7748c6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions client/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use log::*;
use serde_json::{json, Value};
use solana_sdk::{
account::Account,
clock::{Slot, UnixTimestamp, DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT},
clock::{
Slot, UnixTimestamp, DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT,
MAX_HASH_AGE_IN_SECONDS,
},
commitment_config::CommitmentConfig,
epoch_schedule::EpochSchedule,
fee_calculator::{FeeCalculator, FeeRateGovernor},
Expand Down Expand Up @@ -1029,6 +1032,7 @@ impl RpcClient {
}
}
};
let now = Instant::now();
loop {
// Return when default (max) commitment is reached
// Failed transactions have already been eliminated, `is_some` check is sufficient
Expand All @@ -1043,7 +1047,14 @@ impl RpcClient {
MAX_LOCKOUT_HISTORY + 1,
));
sleep(Duration::from_millis(500));
confirmations = self.get_num_blocks_since_signature_confirmation(&signature)?;
confirmations = self
.get_num_blocks_since_signature_confirmation(&signature)
.unwrap_or(confirmations);
if now.elapsed().as_secs() >= MAX_HASH_AGE_IN_SECONDS as u64 {
return Err(
RpcError::ForUser("transaction not finalized. This can happen when a transaction lands in an abandoned fork. Please retry.".to_string()).into(),
);
}
}
}

Expand Down

0 comments on commit e7748c6

Please sign in to comment.