pub struct GasCounter { /* private fields */ }Expand description
Gas counter (a part of VMlogic)
Implementations§
Source§impl GasCounter
impl GasCounter
pub fn new( ext_costs_config: ExtCostsConfig, max_gas_burnt: Gas, prepaid_gas: Gas, is_view: bool, profile: Option<ProfileData>, ) -> Self
pub fn pay_wasm_gas(&mut self, value: u64) -> Result<(), VMLogicError>
pub fn pay_evm_gas(&mut self, value: u64) -> Result<(), VMLogicError>
Sourcepub fn pay_per_byte(
&mut self,
cost: ExtCosts,
num_bytes: u64,
) -> Result<(), VMLogicError>
pub fn pay_per_byte( &mut self, cost: ExtCosts, num_bytes: u64, ) -> Result<(), VMLogicError>
A helper function to pay per byte gas
Sourcepub fn pay_base(&mut self, cost: ExtCosts) -> Result<(), VMLogicError>
pub fn pay_base(&mut self, cost: ExtCosts) -> Result<(), VMLogicError>
A helper function to pay base cost gas
Sourcepub 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;
Sourcepub 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;
Sourcepub 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;
pub fn prepay_gas(&mut self, use_gas: Gas) -> Result<(), VMLogicError>
pub fn burnt_gas(&self) -> Gas
pub fn used_gas(&self) -> Gas
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GasCounter
impl !RefUnwindSafe for GasCounter
impl Send for GasCounter
impl Sync for GasCounter
impl Unpin for GasCounter
impl !UnwindSafe for GasCounter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more