Add struct and convenience methods to track stake activation status (#20392)

* Add struct and convenience methods to track stake activation status

* fix nits

* rename
This commit is contained in:
Justin Starry
2021-10-04 18:59:11 -04:00
committed by GitHub
parent 2b967202f3
commit 0ddb34a0b4
7 changed files with 139 additions and 98 deletions

View File

@@ -39,13 +39,11 @@ use solana_sdk::{
stake::{
self,
instruction::{self as stake_instruction, LockupArgs, StakeError},
state::{Authorized, Lockup, Meta, StakeAuthorize, StakeState},
state::{Authorized, Lockup, Meta, StakeActivationStatus, StakeAuthorize, StakeState},
},
stake_history::StakeHistory,
system_instruction::SystemError,
sysvar::{
clock,
stake_history::{self, StakeHistory},
},
sysvar::{clock, stake_history},
transaction::Transaction,
};
use solana_vote_program::vote_state::VoteState;
@@ -2013,7 +2011,11 @@ pub fn build_stake_state(
stake,
) => {
let current_epoch = clock.epoch;
let (active_stake, activating_stake, deactivating_stake) = stake
let StakeActivationStatus {
effective,
activating,
deactivating,
} = stake
.delegation
.stake_activating_and_deactivating(current_epoch, Some(stake_history));
let lockup = if lockup.is_in_force(clock, None) {
@@ -2048,9 +2050,9 @@ pub fn build_stake_state(
use_lamports_unit,
current_epoch,
rent_exempt_reserve: Some(*rent_exempt_reserve),
active_stake: u64_some_if_not_zero(active_stake),
activating_stake: u64_some_if_not_zero(activating_stake),
deactivating_stake: u64_some_if_not_zero(deactivating_stake),
active_stake: u64_some_if_not_zero(effective),
activating_stake: u64_some_if_not_zero(activating),
deactivating_stake: u64_some_if_not_zero(deactivating),
..CliStakeState::default()
}
}