pub struct GasStatus<'a> { /* private fields */ }
Expand description

The Move VM implementation of state for gas metering.

Initialize with a CostTable and the gas provided to the transaction. Provide all the proper guarantees about gas metering in the Move VM.

Every client must use an instance of this type to interact with the Move VM.

Implementations§

source§

impl<'a> GasStatus<'a>

source

pub fn new(cost_table: &'a CostTable, gas_left: GasUnits<GasCarrier>) -> Self

Initialize the gas state with metering enabled.

Charge for every operation and fail when there is no more gas to pay for operations. This is the instantiation that must be used when executing a user script.

source

pub fn new_unmetered() -> Self

Initialize the gas state with metering disabled.

It should be used by clients in very specific cases and when executing system code that does not have to charge the user.

source

pub fn cost_table(&self) -> &CostTable

Return the CostTable behind this GasStatus.

source

pub fn remaining_gas(&self) -> GasUnits<GasCarrier>

Return the gas left.

source

pub fn deduct_gas( &mut self, amount: InternalGasUnits<GasCarrier> ) -> PartialVMResult<()>

Charge a given amount of gas and fail if not enough gas units are left.

source

pub fn charge_instr_with_size( &mut self, opcode: Opcodes, size: AbstractMemorySize<GasCarrier> ) -> PartialVMResult<()>

Charge an instruction over data with a given size and fail if not enough gas units are left.

source

pub fn charge_instr(&mut self, opcode: Opcodes) -> PartialVMResult<()>

Charge an instruction and fail if not enough gas units are left.

source

pub fn charge_intrinsic_gas( &mut self, intrinsic_cost: AbstractMemorySize<GasCarrier> ) -> VMResult<()>

Charge gas related to the overall size of a transaction and fail if not enough gas units are left.

source

pub fn set_metering(&mut self, enabled: bool)

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for GasStatus<'a>

§

impl<'a> Send for GasStatus<'a>

§

impl<'a> Sync for GasStatus<'a>

§

impl<'a> Unpin for GasStatus<'a>

§

impl<'a> UnwindSafe for GasStatus<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V