GasCounter

Struct GasCounter 

Source
pub struct GasCounter { /* private fields */ }
Expand description

Gas counter (a part of VMlogic)

Implementations§

Source§

impl GasCounter

Source

pub fn new( ext_costs_config: ExtCostsConfig, max_gas_burnt: Gas, prepaid_gas: Gas, is_view: bool, profile: Option<ProfileData>, ) -> Self

Source

pub fn pay_wasm_gas(&mut self, value: u64) -> Result<(), VMLogicError>

Source

pub fn pay_evm_gas(&mut self, value: u64) -> Result<(), VMLogicError>

Source

pub fn pay_per_byte( &mut self, cost: ExtCosts, num_bytes: u64, ) -> Result<(), VMLogicError>

A helper function to pay per byte gas

Source

pub fn pay_base(&mut self, cost: ExtCosts) -> Result<(), VMLogicError>

A helper function to pay base cost gas

Source

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;
Source

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;
Source

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;
Source

pub fn prepay_gas(&mut self, use_gas: Gas) -> Result<(), VMLogicError>

Source

pub fn burnt_gas(&self) -> Gas

Source

pub fn used_gas(&self) -> Gas

Trait Implementations§

Source§

impl Debug for GasCounter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.