gaspowercheck

package
v1.0.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 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

This section is empty.

Types

type Checker

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

Checker which checks gas power

func New

func New(reader DagReader) *Checker

New Checker for gas power

func (*Checker) CalcGasPower

func (v *Checker) CalcGasPower(e *inter.EventHeaderData, selfParent *inter.EventHeaderData) (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.Event, selfParent *inter.EventHeaderData) error

Validate event

type Config

type Config struct {
	Idx                int
	AllocPerSec        uint64
	MaxAllocPeriod     inter.Timestamp
	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 DagReader

type DagReader interface {
	GetValidationContext() *ValidationContext
}

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

type ValidationContext

type ValidationContext struct {
	Epoch                idx.Epoch
	Configs              [2]Config
	Validators           *pos.Validators
	PrevEpochLastHeaders inter.HeadersByCreator
	PrevEpochEndTime     inter.Timestamp
	PrevEpochRefunds     map[idx.StakerID]uint64
}

ValidationContext for gaspower checking

Jump to

Keyboard shortcuts

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