CompressionInfo

Struct CompressionInfo 

Source
pub struct CompressionInfo {
    pub config_version: u16,
    pub lamports_per_write: u32,
    pub last_claimed_slot: u64,
    pub rent_config: RentConfig,
    pub state: CompressionState,
}

Fields§

§config_version: u16

Version of the compressible config used to initialize this account.

§lamports_per_write: u32

Lamports to top up on each write (from config, stored per-account to avoid passing config on every write)

§last_claimed_slot: u64

Slot when rent was last claimed (epoch boundary accounting).

§rent_config: RentConfig

Rent function parameters for determining compressibility/claims.

§state: CompressionState

Account compression state.

Implementations§

Source§

impl CompressionInfo

Source

pub fn new_from_config(cfg: &LightConfig, current_slot: u64) -> Self

Create a new CompressionInfo initialized from a compressible config.

Rent sponsor is always the config’s rent_sponsor (not stored per-account). This means rent always flows to the protocol’s rent pool upon compression, regardless of who paid for account creation.

Source

pub fn new_decompressed() -> Result<Self, ProgramError>

Backward-compat constructor used by older call sites; initializes minimal fields. Rent will flow to config’s rent_sponsor upon compression.

Source

pub fn bump_last_claimed_slot(&mut self) -> Result<(), ProgramError>

Update last_claimed_slot to the current slot.

Source

pub fn set_last_claimed_slot(&mut self, slot: u64)

Explicitly set last_claimed_slot.

Source

pub fn last_claimed_slot(&self) -> u64

Get last_claimed_slot.

Source

pub fn set_compressed(&mut self)

Source

pub fn is_compressed(&self) -> bool

Source§

impl CompressionInfo

Source

pub fn calculate_top_up_lamports( &self, num_bytes: u64, current_slot: u64, current_lamports: u64, rent_exemption_lamports: u64, ) -> u64

Calculate top-up lamports required for a write.

Logic (same as CTokens):

  • If account is compressible (can’t pay current + next epoch): return lamports_per_write + deficit
  • If account has >= max_funded_epochs: return 0 (no top-up needed)
  • Otherwise: return lamports_per_write (maintenance mode)
Source

pub fn top_up_rent<'a>( &self, account_info: &AccountInfo<'a>, payer_info: &AccountInfo<'a>, system_program_info: &AccountInfo<'a>, ) -> Result<(), ProgramError>

Top up rent on write if needed and transfer lamports from payer to account. This is the standard pattern for all write operations on compressible PDAs.

§Arguments
  • account_info - The PDA account to top up
  • payer_info - The payer account (will be debited)
  • system_program_info - The System Program account for CPI
§Returns
  • Ok(()) if top-up succeeded or was not needed
  • Err(ProgramError) if transfer failed

Trait Implementations§

Source§

impl BorshDeserialize for CompressionInfo

Source§

fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for CompressionInfo

Source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl Clone for CompressionInfo

Source§

fn clone(&self) -> CompressionInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompressionInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CompressionInfo

Source§

fn default() -> CompressionInfo

Returns the “default value” for a type. Read more
Source§

impl PartialEq for CompressionInfo

Source§

fn eq(&self, other: &CompressionInfo) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Space for CompressionInfo

Source§

impl StructuralPartialEq for CompressionInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HashToFieldSize for T
where T: BorshSerialize,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.