Struct near_vm_logic::gas_counter::GasCounter [−][src]
pub struct GasCounter { /* fields omitted */ }
Expand description
Gas counter (a part of VMlogic)
Implementations
pub fn new(
ext_costs_config: ExtCostsConfig,
max_gas_burnt: Gas,
opcode_cost: u32,
prepaid_gas: Gas,
is_view: bool
) -> Self
Very special function to get the gas counter pointer for generated machine code.
Please do not use, unless fully understand Rust aliasing and other consequences.
Can be used to emit inlined code like pay_wasm_gas()
, i.e.
mov base, gas_counter_raw_ptr
mov rax, [base + 0] ; current burnt gas
mov rcx, [base + 16] ; opcode cost
imul rcx, block_ops_count ; block cost
add rax, rcx ; new burnt gas
jo emit_integer_overflow
cmp rax, [base + 8] ; unsigned compare with burnt limit
mov [base + 0], rax
ja emit_gas_exceeded
A helper function to pay a multiple of a cost.
A helper function to pay base cost gas.
pub fn pay_action_per_byte(
&mut self,
per_byte_fee: &Fee,
num_bytes: u64,
sir: bool,
action: ActionCosts
) -> Result<(), VMLogicError>
pub fn pay_action_per_byte(
&mut self,
per_byte_fee: &Fee,
num_bytes: u64,
sir: bool,
action: ActionCosts
) -> Result<(), VMLogicError>
A helper function to pay per byte gas fee for batching an action.
Args:
per_byte_fee
: the fee per byte;num_bytes
: the number of bytes;sir
: whether the receiver_id is same as the current account ID;action
: what kind of action is charged for;
pub fn pay_action_base(
&mut self,
base_fee: &Fee,
sir: bool,
action: ActionCosts
) -> Result<(), VMLogicError>
pub fn pay_action_base(
&mut self,
base_fee: &Fee,
sir: bool,
action: ActionCosts
) -> Result<(), VMLogicError>
A helper function to pay base cost gas fee for batching an action.
Args:
base_fee
: base fee for the action;sir
: whether the receiver_id is same as the current account ID;action
: what kind of action is charged for;
pub fn pay_action_accumulated(
&mut self,
burn_gas: Gas,
use_gas: Gas,
action: ActionCosts
) -> Result<(), VMLogicError>
pub fn pay_action_accumulated(
&mut self,
burn_gas: Gas,
use_gas: Gas,
action: ActionCosts
) -> Result<(), VMLogicError>
A helper function to pay base cost gas fee for batching an action.
Args:
burn_gas
: amount of gas to burn;use_gas
: amount of gas to reserve;action
: what kind of action is charged for;