Skip to content

Commit

Permalink
Merge pull request #3734 from anoma/fraccaman/query-active-validators
Browse files Browse the repository at this point in the history
rpc: add query consensus validators
  • Loading branch information
mergify[bot] committed Sep 8, 2024
2 parents 790bd16 + c18b6cb commit 0d7140f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add an RPC endpoint for the consensus validator set in the SDK.
([\#3734](https://github.com/anoma/namada/pull/3734))
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: namada_io::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 0d7140f

Please sign in to comment.