gaspowercheck

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongGasPowerLeft indicates that event's GasPowerLeft is miscalculated.
	ErrWrongGasPowerLeft = errors.New("event has wrong GasPowerLeft")
)

Functions

func CalcValidatorGasPower

func CalcValidatorGasPower(e inter.EventI, eTime, prevTime inter.Timestamp, prevGasPowerLeft uint64, validators *pos.Validators, config Config) uint64

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker which checks gas power

func New

func New(reader Reader) *Checker

New Checker for gas power

func (*Checker) CalcGasPower

func (v *Checker) CalcGasPower(e inter.EventI, selfParent inter.EventI) (inter.GasPowerLeft, error)

CalcGasPower calculates available gas power for the event, i.e. how many gas its content may consume

func (*Checker) Validate

func (v *Checker) Validate(e inter.EventI, selfParent inter.EventI) error

Validate event

type Config

type Config struct {
	Idx                int
	AllocPerSec        uint64
	MaxAllocPeriod     inter.Timestamp
	MinEnsuredAlloc    uint64
	StartupAllocPeriod inter.Timestamp
	MinStartupGas      uint64
}

Config for gaspower checking. There'll be 2 different configs for short-term and long-term gas power checks.

type Reader

type Reader interface {
	GetValidationContext() *ValidationContext
}

Reader is accessed by the validator to get the current state.

type ValidationContext

type ValidationContext struct {
	Epoch           idx.Epoch
	Configs         [inter.GasPowerConfigs]Config
	EpochStart      inter.Timestamp
	Validators      *pos.Validators
	ValidatorStates []ValidatorState
}

ValidationContext for gaspower checking

type ValidatorState

type ValidatorState struct {
	PrevEpochEvent inter.EventI
	GasRefund      uint64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL