Skip to content

Commit

Permalink
rpc: add query consensus validators
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman authored and brentstone committed Sep 6, 2024
1 parent ee4649b commit bf3484d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/sdk/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use namada_parameters::{storage as params_storage, EpochDuration};
use namada_proof_of_stake::parameters::PosParams;
use namada_proof_of_stake::types::{
BondsAndUnbondsDetails, CommissionPair, ValidatorMetaData,
WeightedValidator,
};
use namada_state::LastBlock;
use namada_token::masp::MaspTokenRewardData;
Expand Down Expand Up @@ -740,6 +741,19 @@ pub async fn get_all_validators<C: namada_io::Client + Sync>(
)
}

/// Get all consensus validators in the given epoch
pub async fn get_all_consensus_validators<C: crate::queries::Client + Sync>(
client: &C,
epoch: Epoch,
) -> Result<BTreeSet<WeightedValidator>, error::Error> {
convert_response::<C, _>(
RPC.vp()
.pos()
.consensus_validator_set(client, &Some(epoch))
.await,
)
}

/// Get the total staked tokens in the given epoch
pub async fn get_total_staked_tokens<C: namada_io::Client + Sync>(
client: &C,
Expand Down

0 comments on commit bf3484d

Please sign in to comment.