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

Commit

Permalink
Avoid panic when validator doesn't have performance samples (#15976)
Browse files Browse the repository at this point in the history
(cherry picked from commit ba33c9e)
  • Loading branch information
CriesofCarrots authored and mvines committed Mar 18, 2021
1 parent 5e9ce99 commit d6160f7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,11 +996,12 @@ pub fn process_get_epoch_info(rpc_client: &RpcClient, config: &CliConfig) -> Pro
let epoch_info = rpc_client.get_epoch_info()?;
let average_slot_time_ms = rpc_client
.get_recent_performance_samples(Some(60))
.map(|samples| {
.ok()
.and_then(|samples| {
let (slots, secs) = samples.iter().fold((0, 0), |(slots, secs), sample| {
(slots + sample.num_slots, secs + sample.sample_period_secs)
});
(secs as u64 * 1000) / slots
(secs as u64).saturating_mul(1000).checked_div(slots)
})
.unwrap_or(clock::DEFAULT_MS_PER_SLOT);
let epoch_info = CliEpochInfo {
Expand Down

0 comments on commit d6160f7

Please sign in to comment.