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 committed Aug 30, 2024
1 parent 40ed13a commit a20ac2e
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 @@ -39,6 +39,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_tx::data::{BatchedTxResult, DryRunResult, ResultCode, TxResult};
Expand Down Expand Up @@ -733,6 +734,19 @@ pub async fn get_all_validators<C: crate::queries::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: crate::queries::Client + Sync>(
client: &C,
Expand Down

0 comments on commit a20ac2e

Please sign in to comment.