Skip to main content

realloc_checked_with

Function realloc_checked_with 

Source
pub fn realloc_checked_with(
    rent: &Rent,
    account: &AccountView<'_>,
    new_len: usize,
    payer: Option<&AccountView<'_>>,
) -> ProgramResult
Expand description

Reaping-safe realloc_checked: tops the account up to rent-exemption using the live Rent sysvar, so it stays correct after a rent reprice.

realloc_checked computes its top-up from the hardcoded crate::sysvar::rent_exempt_minimum const, which cannot see a reprice and would UNDER-fund the account (leaving it reapable, data lost) if the cluster ever raised lamports_per_byte_year or the exemption threshold. Any resize whose correctness must survive a reprice should call this variant with a freshly read sysvar:

ⓘ
let rent = hopper::sysvar::Rent::get()?;
hopper::batch::realloc_checked_with(&rent, account, new_len, Some(payer))?;