pub struct StakesView(/* private fields */);Expand description
Read-only view of the stake cache for external consumers (e.g., RPC handlers).
This type wraps a StakesHandle and exposes only read-only query methods.
Mutation methods (insert_stake_account, insert_validator_account, freeze_stakes,
request_epoch_rewards_init, etc.) are intentionally not exposed.
§Usage
External code (outside the svm-execution crate) should use Bank::stakes_view()
to obtain a StakesView instead of accessing the full StakesHandle directly.
This prevents accidental state corruption from RPC handlers or other non-transaction
code paths.
Implementations§
Source§impl StakesView
impl StakesView
Sourcepub fn new(handle: StakesHandle) -> Self
pub fn new(handle: StakesHandle) -> Self
Create a new read-only view from a StakesHandle.
Sourcepub fn get_stake_account_from_pending(
&self,
pubkey: &Pubkey,
) -> Option<StakeAccount>
pub fn get_stake_account_from_pending( &self, pubkey: &Pubkey, ) -> Option<StakeAccount>
Get a stake account starting from pending (next epoch state).
Searches: pending → frozen (newest to oldest) → baseline
Sourcepub fn get_validator_account_from_pending(
&self,
pubkey: &Pubkey,
) -> Option<ValidatorAccount>
pub fn get_validator_account_from_pending( &self, pubkey: &Pubkey, ) -> Option<ValidatorAccount>
Get a validator account starting from pending (next epoch state).
Searches: pending → frozen (newest to oldest) → baseline
Sourcepub fn get_all_validator_accounts_from_pending(
&self,
) -> Vec<(Pubkey, ValidatorAccount)>
pub fn get_all_validator_accounts_from_pending( &self, ) -> Vec<(Pubkey, ValidatorAccount)>
Get all validator accounts starting from pending (next epoch state).
Sourcepub fn get_stake_account_from_last_frozen(
&self,
pubkey: &Pubkey,
) -> Option<StakeAccount>
pub fn get_stake_account_from_last_frozen( &self, pubkey: &Pubkey, ) -> Option<StakeAccount>
Get a stake account starting from the last frozen epoch (current epoch state).
Searches: frozen (newest to oldest) → baseline. Skips pending.
Sourcepub fn get_validator_account_from_last_frozen(
&self,
pubkey: &Pubkey,
) -> Option<ValidatorAccount>
pub fn get_validator_account_from_last_frozen( &self, pubkey: &Pubkey, ) -> Option<ValidatorAccount>
Get a validator account starting from the last frozen epoch (current epoch state).
Searches: frozen (newest to oldest) → baseline. Skips pending.
Sourcepub fn get_all_validator_accounts_from_last_frozen(
&self,
) -> Vec<(Pubkey, ValidatorAccount)>
pub fn get_all_validator_accounts_from_last_frozen( &self, ) -> Vec<(Pubkey, ValidatorAccount)>
Get all validator accounts from the last frozen epoch (current epoch state).
Sourcepub fn last_frozen_timestamp(&self) -> Option<u64>
pub fn last_frozen_timestamp(&self) -> Option<u64>
Get the timestamp of the last frozen epoch (current epoch’s effective state).
Returns None if no frozen snapshots exist yet.
Auto Trait Implementations§
impl Freeze for StakesView
impl !RefUnwindSafe for StakesView
impl Send for StakesView
impl Sync for StakesView
impl Unpin for StakesView
impl UnsafeUnpin for StakesView
impl !UnwindSafe for StakesView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more