Skip to main content

StorageCreditsBackend

Trait StorageCreditsBackend 

Source
pub trait StorageCreditsBackend {
    type Error: StorageCreditsError;

    // Required methods
    fn gas_params(&self) -> &GasParams;
    fn gas_tracker(&mut self) -> &mut GasTracker;
    fn sload(
        &mut self,
        address: Address,
        key: U256,
        skip_cold_load: bool,
    ) -> Result<StateLoad<U256>, Self::Error>;
    fn sstore(
        &mut self,
        address: Address,
        key: U256,
        value: U256,
        skip_cold_load: bool,
    ) -> Result<StateLoad<SStoreResult>, Self::Error>;
    fn tload(&mut self, address: Address, key: U256) -> U256;
    fn tstore(&mut self, address: Address, key: U256, value: U256);
    fn emit_event(
        &mut self,
        address: Address,
        event: LogData,
    ) -> Result<(), Self::Error>;

    // Provided method
    fn charge_gas(&mut self, cost: u64) -> Result<(), Self::Error> { ... }
}
Expand description

Minimal journal/gas operations required by storage credit accounting.

Required Associated Types§

Required Methods§

Source

fn gas_params(&self) -> &GasParams

Gas parameters for the active spec.

Source

fn gas_tracker(&mut self) -> &mut GasTracker

Gas tracker for the active execution context.

Source

fn sload( &mut self, address: Address, key: U256, skip_cold_load: bool, ) -> Result<StateLoad<U256>, Self::Error>

SLOAD address[key], optionally skipping the cold load.

Source

fn sstore( &mut self, address: Address, key: U256, value: U256, skip_cold_load: bool, ) -> Result<StateLoad<SStoreResult>, Self::Error>

SSTORE address[key].

Source

fn tload(&mut self, address: Address, key: U256) -> U256

TLOAD address[key].

Source

fn tstore(&mut self, address: Address, key: U256, value: U256)

TSTORE address[key] = value.

Source

fn emit_event( &mut self, address: Address, event: LogData, ) -> Result<(), Self::Error>

Emits event from address.

Provided Methods§

Source

fn charge_gas(&mut self, cost: u64) -> Result<(), Self::Error>

Charges cost regular gas, returning out_of_gas if insufficient.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§