fn feature_activation_allowed(
    rpc_client: &RpcClient,
    quiet: bool,
) -> Result<(bool, Option<CliClusterFeatureSets>), ClientError> {
    let my_feature_set = solana_version::Version::default().feature_set;

    let feature_set_stats = feature_set_stats(rpc_client)?;

    let (stake_allowed, rpc_allowed) = feature_set_stats
        .get(&my_feature_set)
        .map(
            |FeatureSetStatsEntry {
                 stake_percent,
                 rpc_nodes_percent,
                 ..
             }| (*stake_percent >= 95., *rpc_nodes_percent >= 95.),
        )
        .unwrap_or((false, false));

    let cluster_feature_sets = if quiet {
        None
    } else {
        let mut feature_sets = feature_set_stats
            .into_iter()
            .map(
                |(
                    feature_set,
                    FeatureSetStatsEntry {
                        stake_percent,
                        rpc_nodes_percent: rpc_percent,
                        software_versions,
                    },
                )| {
                    CliFeatureSet {
                        software_versions: software_versions.into_iter().map(CliVersion).collect(),
                        feature_set,
                        stake_percent,
                        rpc_percent,
                    }
                },
            )
            .collect::<Vec<_>>();
        feature_sets.sort_by(|l, r| {
            match l.software_versions[0]
                .cmp(&r.software_versions[0])
                .reverse()
            {
                Ordering::Equal => {
                    match l
                        .stake_percent
                        .partial_cmp(&r.stake_percent)
                        .unwrap()
                        .reverse()
                    {
                        Ordering::Equal => {
                            l.rpc_percent.partial_cmp(&r.rpc_percent).unwrap().reverse()
                        }
                        o => o,
                    }
                }
                o => o,
            }
        });
        Some(CliClusterFeatureSets {
            tool_feature_set: my_feature_set,
            feature_sets,
            stake_allowed,
            rpc_allowed,
        })
    };

    Ok((stake_allowed && rpc_allowed, cluster_feature_sets))
}
// 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
Feature activation is only allowed when 95% of the active stake is on the current feature set
fn feature_activation_allowed(
    rpc_client: &RpcClient,
    quiet: bool,
) -> Result<(bool, Option<CliClusterFeatureSets>), ClientError> {
    let my_feature_set = solana_version::Version::default().feature_set;
    let feature_set_stats = feature_set_stats(rpc_client)?;
    let (stake_allowed, rpc_allowed) = feature_set_stats
        .get(&my_feature_set)
        .map(
            |FeatureSetStatsEntry {
                 stake_percent,
                 rpc_nodes_percent,
                 ..
             }| (*stake_percent >= 95., *rpc_nodes_percent >= 95.),
        )
        .unwrap_or((false, false));
    let cluster_feature_sets = if quiet {
        None
    } else {
        let mut feature_sets = feature_set_stats
            .into_iter()
            .map(
                |(
                    feature_set,
                    FeatureSetStatsEntry {
                        stake_percent,
                        rpc_nodes_percent: rpc_percent,
                        software_versions,
                    },
                )| {
                    CliFeatureSet {
                        software_versions: software_versions.into_iter().map(CliVersion).collect(),
                        feature_set,
                        stake_percent,
                        rpc_percent,
                    }
                },
            )
            .collect::<Vec<_>>();
        feature_sets.sort_by(|l, r| {
            match l.software_versions[0]
                .cmp(&r.software_versions[0])
                .reverse()
            {
                Ordering::Equal => {
                    match l
                        .stake_percent
                        .partial_cmp(&r.stake_percent)
                        .unwrap()
                        .reverse()
                    {
                        Ordering::Equal => {
                            l.rpc_percent.partial_cmp(&r.rpc_percent).unwrap().reverse()
                        }
                        o => o,
                    }
                }
                o => o,
            }
        });
        Some(CliClusterFeatureSets {
            tool_feature_set: my_feature_set,
            feature_sets,
            stake_allowed,
            rpc_allowed,
        })
    };
    Ok((stake_allowed && rpc_allowed, cluster_feature_sets))
}
fn feature_activation_allowed ( rpc_client : & RpcClient , quiet : bool , ) -> Result < ( bool , Option < CliClusterFeatureSets > ) , ClientError > { let my_feature_set = solana_version :: Version :: default ( ) . feature_set ; let feature_set_stats = feature_set_stats ( rpc_client ) ? ; let ( stake_allowed , rpc_allowed ) = feature_set_stats . get ( & my_feature_set ) . map ( | FeatureSetStatsEntry { stake_percent , rpc_nodes_percent , .. } | ( * stake_percent >= 95. , * rpc_nodes_percent >= 95. ) , ) . unwrap_or ( ( false , false ) ) ; let cluster_feature_sets = if quiet { None } else { let mut feature_sets = feature_set_stats . into_iter ( ) . map ( | ( feature_set , FeatureSetStatsEntry { stake_percent , rpc_nodes_percent : rpc_percent , software_versions , } , ) | { CliFeatureSet { software_versions : software_versions . into_iter ( ) . map ( CliVersion ) . collect ( ) , feature_set , stake_percent , rpc_percent , } } , ) . collect :: < Vec < _ > > ( ) ; feature_sets . sort_by ( | l , r | { match l . software_versions [ 0 ] . cmp ( & r . software_versions [ 0 ] ) . reverse ( ) { Ordering :: Equal => { match l . stake_percent . partial_cmp ( & r . stake_percent ) . unwrap ( ) . reverse ( ) { Ordering :: Equal => { l . rpc_percent . partial_cmp ( & r . rpc_percent ) . unwrap ( ) . reverse ( ) } o => o , } } o => o , } } ) ; Some ( CliClusterFeatureSets { tool_feature_set : my_feature_set , feature_sets , stake_allowed , rpc_allowed , } ) } ; Ok ( ( stake_allowed && rpc_allowed , cluster_feature_sets ) ) }
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
rpc_client
&RpcClient
quiet
bool