11use {
2- crate :: PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH ,
32 solana_account_info:: AccountInfo ,
43 solana_clock:: Epoch ,
54 solana_program_error:: ProgramError ,
65 solana_pubkey:: Pubkey ,
76 solana_stake_interface:: {
87 error:: StakeError ,
98 state:: { Delegation , Meta , Stake } ,
10- sysvar:: stake_history:: StakeHistorySysvar ,
119 } ,
1210} ;
1311
@@ -29,46 +27,6 @@ pub(crate) fn new_stake(
2927 }
3028}
3129
32- pub ( crate ) fn redelegate_stake (
33- stake : & mut Stake ,
34- stake_lamports : u64 ,
35- voter_pubkey : & Pubkey ,
36- credits_observed : u64 ,
37- epoch : Epoch ,
38- stake_history : & StakeHistorySysvar ,
39- ) -> Result < ( ) , ProgramError > {
40- // If stake is currently active:
41- if stake. stake (
42- epoch,
43- stake_history,
44- PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH ,
45- ) != 0
46- {
47- // If pubkey of new voter is the same as current,
48- // and we are scheduled to start deactivating this epoch,
49- // we rescind deactivation
50- if stake. delegation . voter_pubkey == * voter_pubkey
51- && epoch == stake. delegation . deactivation_epoch
52- {
53- stake. delegation . deactivation_epoch = u64:: MAX ;
54- return Ok ( ( ) ) ;
55- } else {
56- // can't redelegate to another pubkey if stake is active.
57- return Err ( StakeError :: TooSoonToRedelegate . into ( ) ) ;
58- }
59- }
60- // Either the stake is freshly activated, is active but has been
61- // deactivated this epoch, or has fully de-activated.
62- // Redelegation implies either re-activation or un-deactivation
63-
64- stake. delegation . stake = stake_lamports;
65- stake. delegation . activation_epoch = epoch;
66- stake. delegation . deactivation_epoch = u64:: MAX ;
67- stake. delegation . voter_pubkey = * voter_pubkey;
68- stake. credits_observed = credits_observed;
69- Ok ( ( ) )
70- }
71-
7230/// Ensure the stake delegation amount is valid. This checks that the account
7331/// meets the minimum balance requirements of delegated stake. If not, return
7432/// an error.
0 commit comments