pub struct AccountRentState {
pub num_bytes: u64,
pub current_slot: u64,
pub current_lamports: u64,
pub last_claimed_slot: u64,
}Expand description
Account state information needed for rent calculations
Fields§
§num_bytes: u64Size of the account in bytes
current_slot: u64Current blockchain slot
current_lamports: u64Current account balance in lamports
last_claimed_slot: u64Slot when rent was last claimed
Implementations§
Source§impl AccountRentState
impl AccountRentState
Sourcepub fn get_completed_epochs(&self) -> u64
pub fn get_completed_epochs(&self) -> u64
The number of complete epochs that have passed since rent was last claimed.
Sourcepub fn is_compressible(
&self,
config: &impl RentConfigTrait,
rent_exemption_lamports: u64,
) -> Option<u64>
pub fn is_compressible( &self, config: &impl RentConfigTrait, rent_exemption_lamports: u64, ) -> Option<u64>
Check if the account is compressible based on its rent status. An account becomes compressible when it lacks sufficient rent for the current epoch + 1.
§Returns
Some(deficit): The account is compressible, returns the deficit amount including compression costsNone: The account is not compressible
Sourcepub fn calculate_claimable_rent(
&self,
config: &impl RentConfigTrait,
rent_exemption_lamports: u64,
) -> Option<u64>
pub fn calculate_claimable_rent( &self, config: &impl RentConfigTrait, rent_exemption_lamports: u64, ) -> Option<u64>
Calculate rent that can be claimed for completed epochs.
Rent can only be claimed for fully completed epochs, not the current ongoing epoch. If the account is compressible, returns None (should compress instead of claim).
§Returns
Some(amount): Claimable rent for completed epochsNone: Account is compressible and should be compressed instead
Sourcepub fn calculate_close_distribution(
&self,
config: &impl RentConfigTrait,
rent_exemption_lamports: u64,
) -> CloseDistribution
pub fn calculate_close_distribution( &self, config: &impl RentConfigTrait, rent_exemption_lamports: u64, ) -> CloseDistribution
Calculate how lamports are distributed when closing an account.
When a compressible account is closed:
- Completed epoch rent goes to the rent sponsor
- Partial epoch rent (unutilized) is returned to the user
§Returns
A CloseDistribution specifying how lamports are split
Sourcepub fn epochs_funded_ahead(
&self,
config: &impl RentConfigTrait,
rent_exemption_lamports: u64,
) -> u64
pub fn epochs_funded_ahead( &self, config: &impl RentConfigTrait, rent_exemption_lamports: u64, ) -> u64
Trait Implementations§
Source§impl Clone for AccountRentState
impl Clone for AccountRentState
Source§fn clone(&self) -> AccountRentState
fn clone(&self) -> AccountRentState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more