Skip 'Stake by Feature Set' output when showing status of a single feature

This commit is contained in:
Michael Vines
2020-10-20 21:34:51 -07:00
committed by mergify[bot]
parent d63cf1e30a
commit ad65d4785e

View File

@ -230,7 +230,7 @@ fn active_stake_by_feature_set(rpc_client: &RpcClient) -> Result<HashMap<u32, u6
} }
// Feature activation is only allowed when 95% of the active stake is on the current feature set // Feature activation is only allowed when 95% of the active stake is on the current feature set
fn feature_activation_allowed(rpc_client: &RpcClient) -> Result<bool, ClientError> { fn feature_activation_allowed(rpc_client: &RpcClient, quiet: bool) -> Result<bool, ClientError> {
let my_feature_set = solana_version::Version::default().feature_set; let my_feature_set = solana_version::Version::default().feature_set;
let active_stake_by_feature_set = active_stake_by_feature_set(rpc_client)?; let active_stake_by_feature_set = active_stake_by_feature_set(rpc_client)?;
@ -240,8 +240,8 @@ fn feature_activation_allowed(rpc_client: &RpcClient) -> Result<bool, ClientErro
.map(|percentage| *percentage >= 95) .map(|percentage| *percentage >= 95)
.unwrap_or(false); .unwrap_or(false);
if !feature_activation_allowed { if !feature_activation_allowed && !quiet {
println!("\n{}", style("Stake By Feature Set:").bold()); println!("{}", style("Stake By Feature Set:").bold());
for (feature_set, percentage) in active_stake_by_feature_set.iter() { for (feature_set, percentage) in active_stake_by_feature_set.iter() {
if *feature_set == 0 { if *feature_set == 0 {
println!("unknown - {}%", percentage); println!("unknown - {}%", percentage);
@ -258,6 +258,7 @@ fn feature_activation_allowed(rpc_client: &RpcClient) -> Result<bool, ClientErro
); );
} }
} }
println!();
} }
Ok(feature_activation_allowed) Ok(feature_activation_allowed)
@ -299,9 +300,10 @@ fn process_status(
}); });
} }
let feature_activation_allowed = feature_activation_allowed(rpc_client, features.len() <= 1)?;
let feature_set = CliFeatures { let feature_set = CliFeatures {
features, features,
feature_activation_allowed: feature_activation_allowed(rpc_client)?, feature_activation_allowed,
inactive, inactive,
}; };
Ok(config.output_format.formatted_string(&feature_set)) Ok(config.output_format.formatted_string(&feature_set))
@ -323,7 +325,7 @@ fn process_activate(
} }
} }
if !feature_activation_allowed(rpc_client)? { if !feature_activation_allowed(rpc_client, false)? {
return Err("Feature activation is not allowed at this time".into()); return Err("Feature activation is not allowed at this time".into());
} }