gasprices

package
v0.0.0-...-412688d Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLinearInterpolationFn

func GetLinearInterpolationFn(getX func() float64, x1 float64, x2 float64, y1 float64, y2 float64) func() float64

LinearInterpolation can be used to dynamically update target gas per second

Types

type GasPriceUpdater

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

func NewGasPriceUpdater

func NewGasPriceUpdater(
	gasPricer *GasPricer,
	epochStartBlockNumber uint64,
	averageBlockGasLimit uint64,
	epochLengthSeconds uint64,
	getLatestBlockNumberFn GetLatestBlockNumberFn,
	getGasUsedByBlockFn GetGasUsedByBlockFn,
	updateL2GasPriceFn UpdateL2GasPriceFn,
) (*GasPriceUpdater, error)

func (*GasPriceUpdater) GetGasPrice

func (g *GasPriceUpdater) GetGasPrice() uint64

func (*GasPriceUpdater) UpdateGasPrice

func (g *GasPriceUpdater) UpdateGasPrice() error

type GasPricer

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

func NewGasPricer

func NewGasPricer(curPrice, floorPrice uint64, getTargetGasPerSecond GetTargetGasPerSecond, maxPercentChangePerEpoch float64) (*GasPricer, error)

NewGasPricer creates a GasPricer and checks its config beforehand

func (*GasPricer) CalcNextEpochGasPrice

func (p *GasPricer) CalcNextEpochGasPrice(avgGasPerSecondLastEpoch float64) (uint64, error)

CalcNextEpochGasPrice calculates the next gas price given some average gas per second over the last epoch

func (*GasPricer) CompleteEpoch

func (p *GasPricer) CompleteEpoch(avgGasPerSecondLastEpoch float64) (uint64, error)

CompleteEpoch ends the current epoch and updates the current gas price for the next epoch

type GetGasUsedByBlockFn

type GetGasUsedByBlockFn func(*big.Int) (uint64, error)

type GetLatestBlockNumberFn

type GetLatestBlockNumberFn func() (uint64, error)

type GetTargetGasPerSecond

type GetTargetGasPerSecond func() float64

type UpdateL2GasPriceFn

type UpdateL2GasPriceFn func(uint64) error

Jump to

Keyboard shortcuts

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