Struct solana_runtime::stakes::Stakes
source · pub struct Stakes<T: Clone> {
vote_accounts: VoteAccounts,
stake_delegations: ImHashMap<Pubkey, T>,
unused: u64,
epoch: Epoch,
stake_history: StakeHistory,
}
Expand description
The generic type T is either Delegation or StakeAccount.
Stakes<Delegation>
is equivalent to the old code and is used for backward
compatibility in crate::bank::BankFieldsToDeserialize
.
But banks cache Stakes<StakeAccount>
which includes the entire stake
account and StakeState deserialized from the account. Doing so, will remove
the need to load the stake account from accounts-db when working with
stake-delegations.
Fields§
§vote_accounts: VoteAccounts
vote accounts
stake_delegations: ImHashMap<Pubkey, T>
stake_delegations
unused: u64
unused
epoch: Epoch
current epoch, used to calculate current stake
stake_history: StakeHistory
history of staking levels
Implementations§
source§impl<T: Clone> Stakes<T>
impl<T: Clone> Stakes<T>
pub fn vote_accounts(&self) -> &VoteAccounts
pub(crate) fn staked_nodes(&self) -> Arc<HashMap<Pubkey, u64>>
source§impl Stakes<StakeAccount<Delegation>>
impl Stakes<StakeAccount<Delegation>>
sourcepub(crate) fn new<F>(
stakes: &Stakes<Delegation>,
get_account: F
) -> Result<Self, Error>where
F: Fn(&Pubkey) -> Option<AccountSharedData>,
pub(crate) fn new<F>( stakes: &Stakes<Delegation>, get_account: F ) -> Result<Self, Error>where F: Fn(&Pubkey) -> Option<AccountSharedData>,
Creates a Stake
pub(crate) fn history(&self) -> &StakeHistory
fn activate_epoch(&mut self, next_epoch: Epoch, thread_pool: &ThreadPool)
sourcefn calculate_stake(
&self,
voter_pubkey: &Pubkey,
epoch: Epoch,
stake_history: &StakeHistory
) -> u64
fn calculate_stake( &self, voter_pubkey: &Pubkey, epoch: Epoch, stake_history: &StakeHistory ) -> u64
Sum the stakes that point to the given voter_pubkey
sourcepub(crate) fn vote_balance_and_staked(&self) -> u64
pub(crate) fn vote_balance_and_staked(&self) -> u64
Sum the lamports of the vote accounts and the delegated stake