AllocationAccount

Trait AllocationAccount 

Source
pub trait AllocationAccount: Send + Sync {
    // Required methods
    fn check(&self) -> Result<(), ProgramStop>;
    fn admit(&self, cost: AllocationCost) -> Result<(), ProgramStop>;
    fn refund(&self, bytes: u64, class: AllocationClass);
    fn stop(&self, stop: ProgramStop) -> ProgramStop;

    // Provided method
    fn observe(&self, _event: StorageEvent, _class: AllocationClass) { ... }
}
Expand description

Implementations must allocate nothing, never panic, and consult no ambient account. Refund is cleanup-only and must validate category and total before subtracting. Admission commits cancellation/terminal checks under its ledger lock. Existing cumulative costs are never refunded. This is not source authority.

Required Methods§

Source

fn check(&self) -> Result<(), ProgramStop>

Source

fn admit(&self, cost: AllocationCost) -> Result<(), ProgramStop>

Source

fn refund(&self, bytes: u64, class: AllocationClass)

Source

fn stop(&self, stop: ProgramStop) -> ProgramStop

Provided Methods§

Source

fn observe(&self, _event: StorageEvent, _class: AllocationClass)

Optional actual-storage observation, after delegated Global operations.

Implementors§