tollstation

package
v0.0.0-...-87e38ef Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//  ErrTollOverflow occurs when the module's toll is larger than its cap
	ErrTollOverflow = errors.New("toll overflow")
)

Functions

This section is empty.

Types

type SimpleTollStation

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

SimpleTollStation is a simple toll station which charge 1 unit toll per op/instr

func NewSimpleTollStation

func NewSimpleTollStation(max uint64) *SimpleTollStation

NewSimpleTollStation creates a new SimpleTollStation, by default the cap/max of toll is math.MaxUint64

func (*SimpleTollStation) AddToll

func (ts *SimpleTollStation) AddToll(toll uint64) error

AddToll adds 1 unit toll per opcode

func (*SimpleTollStation) GetOpPrice

func (ts *SimpleTollStation) GetOpPrice(_ expr.OpCode) uint64

GetOpPrice will get the price of one opcode

func (*SimpleTollStation) GetToll

func (ts *SimpleTollStation) GetToll() uint64

GetToll returns the total count in the toll station

type TollStation

type TollStation interface {
	GetOpPrice(expr.OpCode) uint64
	GetToll() uint64
	AddToll(uint64) error
}

TollStation is an interface which acts as a toll counter on the cost of one module

Jump to

Keyboard shortcuts

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