Struct move_vm_types::gas_schedule::GasStatus
source · 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>
impl<'a> GasStatus<'a>
sourcepub fn new(cost_table: &'a CostTable, gas_left: GasUnits<GasCarrier>) -> Self
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.
sourcepub fn new_unmetered() -> Self
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.
sourcepub fn cost_table(&self) -> &CostTable
pub fn cost_table(&self) -> &CostTable
Return the CostTable
behind this GasStatus
.
sourcepub fn remaining_gas(&self) -> GasUnits<GasCarrier>
pub fn remaining_gas(&self) -> GasUnits<GasCarrier>
Return the gas left.
sourcepub fn deduct_gas(
&mut self,
amount: InternalGasUnits<GasCarrier>
) -> PartialVMResult<()>
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.
sourcepub fn charge_instr_with_size(
&mut self,
opcode: Opcodes,
size: AbstractMemorySize<GasCarrier>
) -> PartialVMResult<()>
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.
sourcepub fn charge_instr(&mut self, opcode: Opcodes) -> PartialVMResult<()>
pub fn charge_instr(&mut self, opcode: Opcodes) -> PartialVMResult<()>
Charge an instruction and fail if not enough gas units are left.
sourcepub fn charge_intrinsic_gas(
&mut self,
intrinsic_cost: AbstractMemorySize<GasCarrier>
) -> VMResult<()>
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.