Documentation ¶
Index ¶
- Constants
- Variables
- type ExecutionEffortWeights
- type ExecutionMemoryWeights
- type Meter
- func (m *Meter) ComputationIntensities() interfaceMeter.MeteredComputationIntensities
- func (m *Meter) MemoryIntensities() interfaceMeter.MeteredMemoryIntensities
- func (m *Meter) MergeMeter(child interfaceMeter.Meter, enforceLimits bool) error
- func (m *Meter) MeterComputation(kind common.ComputationKind, intensity uint) error
- func (m *Meter) MeterMemory(kind common.MemoryKind, intensity uint) error
- func (m *Meter) NewChild() interfaceMeter.Meter
- func (m *Meter) SetComputationWeights(weights ExecutionEffortWeights)
- func (m *Meter) SetMemoryWeights(weights ExecutionMemoryWeights)
- func (m *Meter) SetTotalMemoryLimit(limit uint64)
- func (m *Meter) TotalComputationLimit() uint
- func (m *Meter) TotalComputationUsed() uint
- func (m *Meter) TotalMemoryLimit() uint
- func (m *Meter) TotalMemoryUsed() uint
- type WeightedMeterOptions
Constants ¶
const MeterExecutionInternalPrecisionBytes = 16
MeterExecutionInternalPrecisionBytes are the amount of bytes that are used internally by the Meter to allow for metering computation smaller than one unit of computation. This allows for more fine weights. A weight of 1 unit of computation is equal to 1<<16. The minimum possible weight is 1/65536.
Variables ¶
var ( // DefaultComputationWeights is the default weights for computation intensities // these weighs make the computation metering the same as it was before dynamic execution fees DefaultComputationWeights = ExecutionEffortWeights{ common.ComputationKindStatement: 1 << MeterExecutionInternalPrecisionBytes, common.ComputationKindLoop: 1 << MeterExecutionInternalPrecisionBytes, common.ComputationKindFunctionInvocation: 1 << MeterExecutionInternalPrecisionBytes, } // DefaultMemoryWeights are currently hard-coded here. In the future we might like to // define this in a contract similar to the computation weights DefaultMemoryWeights = ExecutionMemoryWeights{}/* 176 elements not displayed */ )
Functions ¶
This section is empty.
Types ¶
type ExecutionEffortWeights ¶ added in v0.26.0
type ExecutionEffortWeights map[common.ComputationKind]uint64
type ExecutionMemoryWeights ¶ added in v0.26.0
type ExecutionMemoryWeights map[common.MemoryKind]uint64
type Meter ¶
type Meter struct {
// contains filtered or unexported fields
}
Meter collects memory and computation usage and enforces limits for any each memory/computation usage call it sums intensity multiplied by the weight of the intensity to the total memory/computation usage metrics and returns error if limits are not met.
func NewMeter ¶
func NewMeter(computationLimit, memoryLimit uint, options ...WeightedMeterOptions) *Meter
NewMeter constructs a new Meter
func (*Meter) ComputationIntensities ¶
func (m *Meter) ComputationIntensities() interfaceMeter.MeteredComputationIntensities
ComputationIntensities returns all the measured computational intensities
func (*Meter) MemoryIntensities ¶
func (m *Meter) MemoryIntensities() interfaceMeter.MeteredMemoryIntensities
MemoryIntensities returns all the measured memory intensities
func (*Meter) MergeMeter ¶
func (m *Meter) MergeMeter(child interfaceMeter.Meter, enforceLimits bool) error
MergeMeter merges the input meter into the current meter and checks for the limits
func (*Meter) MeterComputation ¶
func (m *Meter) MeterComputation(kind common.ComputationKind, intensity uint) error
MeterComputation captures computation usage and returns an error if it goes beyond the limit
func (*Meter) MeterMemory ¶
func (m *Meter) MeterMemory(kind common.MemoryKind, intensity uint) error
MeterMemory captures memory usage and returns an error if it goes beyond the limit
func (*Meter) NewChild ¶
func (m *Meter) NewChild() interfaceMeter.Meter
NewChild construct a new Meter instance with the same limits as parent
func (*Meter) SetComputationWeights ¶
func (m *Meter) SetComputationWeights(weights ExecutionEffortWeights)
SetComputationWeights sets the computation weights
func (*Meter) SetMemoryWeights ¶
func (m *Meter) SetMemoryWeights(weights ExecutionMemoryWeights)
SetMemoryWeights sets the memory weights
func (*Meter) SetTotalMemoryLimit ¶ added in v0.26.2
SetTotalMemoryLimit sets the total memory limit
func (*Meter) TotalComputationLimit ¶
TotalComputationLimit returns the total computation limit
func (*Meter) TotalComputationUsed ¶
TotalComputationUsed returns the total computation used
func (*Meter) TotalMemoryLimit ¶
TotalMemoryLimit returns the total memory limit
func (*Meter) TotalMemoryUsed ¶
TotalMemoryUsed returns the total memory used
type WeightedMeterOptions ¶
type WeightedMeterOptions func(*Meter)
func WithComputationWeights ¶
func WithComputationWeights(weights ExecutionEffortWeights) WeightedMeterOptions
WithComputationWeights sets the weights for computation intensities
func WithMemoryWeights ¶
func WithMemoryWeights(weights ExecutionMemoryWeights) WeightedMeterOptions
WithMemoryWeights sets the weights for the memory intensities