Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Jun 1, 2023
1 parent 6c52039 commit 5db005e
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 98 deletions.
6 changes: 3 additions & 3 deletions account-decoder/src/parse_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn parse_stake(data: &[u8]) -> Result<StakeAccountType, ParseAccountError> {
meta: meta.into(),
stake: None,
}),
StakeState::Stake(meta, stake) => StakeAccountType::Delegated(UiStakeAccount {
StakeState::Stake(meta, stake, _) => StakeAccountType::Delegated(UiStakeAccount {
meta: meta.into(),
stake: Some(stake.into()),
}),
Expand Down Expand Up @@ -136,7 +136,7 @@ impl From<Delegation> for UiDelegation {

#[cfg(test)]
mod test {
use {super::*, bincode::serialize};
use {super::*, bincode::serialize, solana_sdk::stake::state::DeactivationFlag};

#[test]
fn test_parse_stake() {
Expand Down Expand Up @@ -194,7 +194,7 @@ mod test {
credits_observed: 10,
};

let stake_state = StakeState::Stake(meta, stake);
let stake_state = StakeState::Stake(meta, stake, DeactivationFlag::Empty);
let stake_data = serialize(&stake_state).unwrap();
assert_eq!(
parse_stake(&stake_data).unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ pub fn process_show_stakes(
});
}
}
StakeState::Stake(_, stake) => {
StakeState::Stake(_, stake, _) => {
if vote_account_pubkeys.is_none()
|| vote_account_pubkeys
.unwrap()
Expand Down
3 changes: 2 additions & 1 deletion cli/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ pub fn process_deactivate_stake_account(

let vote_account_address = match stake_account.state() {
Ok(stake_state) => match stake_state {
StakeState::Stake(_, stake) => stake.delegation.voter_pubkey,
StakeState::Stake(_, stake, _) => stake.delegation.voter_pubkey,
_ => {
return Err(CliError::BadParameter(format!(
"{stake_account_address} is not a delegated stake account",
Expand Down Expand Up @@ -2195,6 +2195,7 @@ pub fn build_stake_state(
lockup,
},
stake,
_,
) => {
let current_epoch = clock.epoch;
let StakeActivationStatus {
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn test_stake_redelegation() {
let stake_state: StakeState = stake_account.state().unwrap();

let rent_exempt_reserve = match stake_state {
StakeState::Stake(meta, stake) => {
StakeState::Stake(meta, stake, _) => {
assert_eq!(stake.delegation.voter_pubkey, vote_keypair.pubkey());
meta.rent_exempt_reserve
}
Expand Down Expand Up @@ -270,7 +270,7 @@ fn test_stake_redelegation() {
let stake2_state: StakeState = stake2_account.state().unwrap();

match stake2_state {
StakeState::Stake(_meta, stake) => {
StakeState::Stake(_meta, stake, _) => {
assert_eq!(stake.delegation.voter_pubkey, vote2_keypair.pubkey());
}
_ => panic!("Unexpected stake2 state!"),
Expand Down
2 changes: 1 addition & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2861,7 +2861,7 @@ fn main() {
.unwrap()
.into_iter()
{
if let Ok(StakeState::Stake(meta, stake)) = account.state() {
if let Ok(StakeState::Stake(meta, stake, _)) = account.state() {
if vote_accounts_to_destake
.contains(&stake.delegation.voter_pubkey)
{
Expand Down
Loading

0 comments on commit 5db005e

Please sign in to comment.