#[repr(C)]pub struct Rent {
pub lamports_per_byte_year: u64,
pub exemption_threshold: f64,
pub burn_percent: u8,
}Expand description
Rent sysvar data.
Fields§
§lamports_per_byte_year: u64§exemption_threshold: f64§burn_percent: u8Implementations§
Source§impl Rent
impl Rent
Sourcepub fn get() -> Result<Self, ProgramError>
pub fn get() -> Result<Self, ProgramError>
Read the Rent sysvar.
Method-style alias for get_rent, matching the Sysvar::get()
ergonomics other Solana frameworks expose (Rent::get()).
Sourcepub fn minimum_balance(&self, data_len: usize) -> u64
pub fn minimum_balance(&self, data_len: usize) -> u64
Minimum lamports for rent exemption at data_len, computed from the
live sysvar values, the correct source for reaping-relevant
decisions after a rent reprice.
This follows Solana’s own solana_rent::Rent::minimum_balance for the
two thresholds any cluster has stored, with no floating point at all:
integer_part = (ACCOUNT_STORAGE_OVERHEAD + data_len) * rate
threshold 1.0 => integer_part
threshold 2.0 => integer_part * 2
otherwise => integer_part * ceil(threshold) (never below Solana's
`(integer_part as f64 * threshold) as u64`)SIMD-0194 made 1.0 the live wire marker and moved the full price into
the rate field; 2.0 is the launch-era value. Both are matched by bit
pattern (see scale_by_exemption_threshold), so a program that reads
the sysvar links no soft-float code. A threshold no cluster has ever
used rounds up to whole years, which can only overfund.
The integer product uses saturating ops purely as an overflow guard;
for every loader-permitted data_len (<= 10_485_760) and realistic
lamports_per_byte_year it never saturates, so the byte-match with the
runtime is exact (proven in the Kani harnesses below).