gear_core::gas

Trait CountersOwner

Source
pub trait CountersOwner {
    // Required methods
    fn charge_gas_for_token(
        &mut self,
        token: CostToken,
    ) -> Result<(), ChargeError>;
    fn charge_gas_if_enough(&mut self, amount: u64) -> Result<(), ChargeError>;
    fn gas_left(&self) -> GasLeft;
    fn current_counter_type(&self) -> CounterType;
    fn decrease_current_counter_to(&mut self, amount: u64);
    fn define_current_counter(&mut self) -> u64;

    // Provided method
    fn current_counter_value(&self) -> u64 { ... }
}
Expand description

Counters owner can change gas limit and allowance counters.

Required Methods§

Source

fn charge_gas_for_token(&mut self, token: CostToken) -> Result<(), ChargeError>

Charge for runtime api call.

Source

fn charge_gas_if_enough(&mut self, amount: u64) -> Result<(), ChargeError>

Charge gas if enough, else just returns error.

Source

fn gas_left(&self) -> GasLeft

Returns gas limit and gas allowance left.

Source

fn current_counter_type(&self) -> CounterType

Currently set gas counter type.

Source

fn decrease_current_counter_to(&mut self, amount: u64)

Decreases gas left by fetched single numeric of actual counter.

Source

fn define_current_counter(&mut self) -> u64

Returns minimal amount of gas counters and set the type of current counter.

Provided Methods§

Source

fn current_counter_value(&self) -> u64

Returns value of gas counter currently set.

Implementors§