epoch-info: Add epochCompletedPercent field to json output
This commit is contained in:
parent
e3d1fe52a2
commit
9547b00f4c
|
@ -251,6 +251,7 @@ pub struct CliSlotStatus {
|
|||
pub struct CliEpochInfo {
|
||||
#[serde(flatten)]
|
||||
pub epoch_info: EpochInfo,
|
||||
pub epoch_completed_percent: f64,
|
||||
#[serde(skip)]
|
||||
pub average_slot_time_ms: u64,
|
||||
#[serde(skip)]
|
||||
|
@ -285,10 +286,7 @@ impl fmt::Display for CliEpochInfo {
|
|||
writeln_name_value(
|
||||
f,
|
||||
"Epoch Completed Percent:",
|
||||
&format!(
|
||||
"{:>3.3}%",
|
||||
self.epoch_info.slot_index as f64 / self.epoch_info.slots_in_epoch as f64 * 100_f64
|
||||
),
|
||||
&format!("{:>3.3}%", self.epoch_completed_percent),
|
||||
)?;
|
||||
let remaining_slots_in_epoch = self.epoch_info.slots_in_epoch - self.epoch_info.slot_index;
|
||||
writeln_name_value(
|
||||
|
|
|
@ -1101,8 +1101,11 @@ pub fn process_get_epoch(rpc_client: &RpcClient, _config: &CliConfig) -> Process
|
|||
|
||||
pub fn process_get_epoch_info(rpc_client: &RpcClient, config: &CliConfig) -> ProcessResult {
|
||||
let epoch_info = rpc_client.get_epoch_info()?;
|
||||
let epoch_completed_percent =
|
||||
epoch_info.slot_index as f64 / epoch_info.slots_in_epoch as f64 * 100_f64;
|
||||
let mut cli_epoch_info = CliEpochInfo {
|
||||
epoch_info,
|
||||
epoch_completed_percent,
|
||||
average_slot_time_ms: 0,
|
||||
start_block_time: None,
|
||||
current_block_time: None,
|
||||
|
|
Loading…
Reference in New Issue