calculate stake from activated amount (#4630)
This commit is contained in:
@ -51,12 +51,27 @@ impl StakeState {
|
||||
Self::from(account).and_then(|state: Self| state.voter_pubkey())
|
||||
}
|
||||
|
||||
// utility function, used by Stakes, tests
|
||||
pub fn voter_pubkey_and_stake_from(account: &Account) -> Option<(Pubkey, u64)> {
|
||||
Self::from(account).and_then(|state: Self| state.voter_pubkey_and_stake())
|
||||
}
|
||||
|
||||
pub fn voter_pubkey(&self) -> Option<Pubkey> {
|
||||
match self {
|
||||
StakeState::Stake { voter_pubkey, .. } => Some(*voter_pubkey),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn voter_pubkey_and_stake(&self) -> Option<(Pubkey, u64)> {
|
||||
match self {
|
||||
StakeState::Stake {
|
||||
voter_pubkey,
|
||||
stake,
|
||||
..
|
||||
} => Some((*voter_pubkey, *stake)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn calculate_rewards(
|
||||
credits_observed: u64,
|
||||
|
Reference in New Issue
Block a user