pub struct ConstantCostRules { /* private fields */ }
Expand description
A type that implements Rules
so that every instruction costs the same.
This is a simplification that is mostly useful for development and testing.
§Note
In a production environment it usually makes no sense to assign every instruction
the same cost. A proper implemention of Rules
should be prived that is probably
created by benchmarking.
Implementations§
source§impl ConstantCostRules
impl ConstantCostRules
sourcepub fn new(instruction_cost: u64, memory_grow_cost: u32) -> Self
pub fn new(instruction_cost: u64, memory_grow_cost: u32) -> Self
Create a new ConstantCostRules
.
Uses instruction_cost
for every instruction and memory_grow_cost
to dynamically
meter the memory growth instruction.
Trait Implementations§
source§impl Default for ConstantCostRules
impl Default for ConstantCostRules
source§impl Rules for ConstantCostRules
impl Rules for ConstantCostRules
source§fn instruction_cost(&self, i: &Operator<'_>) -> Result<InstructionCost>
fn instruction_cost(&self, i: &Operator<'_>) -> Result<InstructionCost>
Returns the cost for the passed
instruction
. Read moresource§fn gas_charge_cost(&self) -> u64
fn gas_charge_cost(&self) -> u64
Returns cost for each call to the gas charging function
source§fn linear_calc_cost(&self) -> u64
fn linear_calc_cost(&self) -> u64
Returns cost of calculating linear cost at runtime. Does not apply to
instructions cost of which can be statically determined (linearly priced
ops proceded by a const). Added to gas_charge_cost on dynamic charges
Auto Trait Implementations§
impl Freeze for ConstantCostRules
impl RefUnwindSafe for ConstantCostRules
impl Send for ConstantCostRules
impl Sync for ConstantCostRules
impl Unpin for ConstantCostRules
impl UnwindSafe for ConstantCostRules
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