pub struct Gasometer { /* private fields */ }Expand description
Custom Gasometer to record costs in precompiles. It is advised to record known costs as early as possible to avoid unecessary computations if there is an Out of Gas.
Implementations§
Source§impl Gasometer
impl Gasometer
Sourcepub fn new(target_gas: Option<u64>) -> Self
pub fn new(target_gas: Option<u64>) -> Self
Create a new Gasometer with provided gas limit. None is no limit.
Sourcepub fn record_cost(&mut self, cost: u64) -> EvmResult
pub fn record_cost(&mut self, cost: u64) -> EvmResult
Record cost, and return error if it goes out of gas.
Sourcepub fn record_log_costs_manual(
&mut self,
topics: usize,
data_len: usize,
) -> EvmResult
pub fn record_log_costs_manual( &mut self, topics: usize, data_len: usize, ) -> EvmResult
Record cost of a log manualy. This can be useful to record log costs early when their content have static size.
Sourcepub fn record_log_costs(&mut self, logs: &[Log]) -> EvmResult
pub fn record_log_costs(&mut self, logs: &[Log]) -> EvmResult
Record cost of logs.
Sourcepub fn remaining_gas(&self) -> EvmResult<Option<u64>>
pub fn remaining_gas(&self) -> EvmResult<Option<u64>>
Compute remaining gas. Returns error if out of gas. Returns None if no gas limit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Gasometer
impl RefUnwindSafe for Gasometer
impl Send for Gasometer
impl Sync for Gasometer
impl Unpin for Gasometer
impl UnwindSafe for Gasometer
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