Skip to content

Commit 945a203

Browse files
authored
CLI: Display validator index in stake pool list output (#519)
feat: show index
1 parent c98cee7 commit 945a203

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

clients/cli/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,8 @@ fn command_list(config: &Config, stake_pool_address: &Pubkey) -> CommandResult {
14181418
let cli_stake_pool_stake_account_infos = validator_list
14191419
.validators
14201420
.iter()
1421-
.map(|validator| {
1421+
.enumerate()
1422+
.map(|(index, validator)| {
14221423
let validator_seed = NonZeroU32::new(validator.validator_seed_suffix.into());
14231424
let (stake_account_address, _) = find_stake_program_address(
14241425
&config.stake_pool_program_id,
@@ -1434,6 +1435,7 @@ fn command_list(config: &Config, stake_pool_address: &Pubkey) -> CommandResult {
14341435
);
14351436
let update_required = u64::from(validator.last_update_epoch) != epoch_info.epoch;
14361437
CliStakePoolStakeAccountInfo {
1438+
index,
14371439
vote_account_address: validator.vote_account_address.to_string(),
14381440
stake_account_address: stake_account_address.to_string(),
14391441
validator_active_stake_lamports: validator.active_stake_lamports.into(),

clients/cli/src/output.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ impl VerboseDisplay for CliStakePoolDetails {
305305
for stake_account in &self.stake_accounts {
306306
writeln!(
307307
w,
308-
"Vote Account: {}\tStake Account: {}\tActive Balance: {}\tTransient Stake Account: {}\tTransient Balance: {}\tLast Update Epoch: {}{}",
308+
"Index: {}\tVote Account: {}\tStake Account: {}\tActive Balance: {}\tTransient Stake Account: {}\tTransient Balance: {}\tLast Update Epoch: {}{}",
309+
stake_account.index,
309310
stake_account.vote_account_address,
310311
stake_account.stake_account_address,
311312
Sol(stake_account.validator_active_stake_lamports),
@@ -347,6 +348,7 @@ impl VerboseDisplay for CliStakePoolDetails {
347348
#[derive(Serialize, Deserialize)]
348349
#[serde(rename_all = "camelCase")]
349350
pub(crate) struct CliStakePoolStakeAccountInfo {
351+
pub index: usize,
350352
pub vote_account_address: String,
351353
pub stake_account_address: String,
352354
pub validator_active_stake_lamports: u64,

0 commit comments

Comments
 (0)