gasprice

package
v0.0.1-RC3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: GPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllBatches

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

AllBatches struct for all batches avg price strategy.

func NewEstimatorAllBatches

func NewEstimatorAllBatches() *AllBatches

NewEstimatorAllBatches init gas price estimator for all batches strategy.

func (*AllBatches) GetAvgGasPrice

func (g *AllBatches) GetAvgGasPrice(ctx context.Context) (*big.Int, error)

GetAvgGasPrice get avg gas price from all blocks.

func (*AllBatches) UpdateGasPriceAvg

func (g *AllBatches) UpdateGasPriceAvg(newValue *big.Int)

UpdateGasPriceAvg Updates the rolling average value of the gas price.

type Config

type Config struct {
	Type EstimatorType `mapstructure:"Type"`

	DefaultGasPriceWei uint64   `mapstructure:"DefaultGasPriceWei"`
	MaxPrice           *big.Int `mapstructure:"MaxPrice"`
	IgnorePrice        *big.Int `mapstructure:"IgnorePrice"`
	CheckBlocks        int      `mapstructure:"CheckBlocks"`
	Percentile         int      `mapstructure:"Percentile"`
}

Config for gas price estimator.

type Default

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

Default gas price from config is set.

func NewDefaultEstimator

func NewDefaultEstimator(cfg Config, pool pool) *Default

NewDefaultEstimator init default gas price estimator.

func (*Default) GetAvgGasPrice

func (d *Default) GetAvgGasPrice(ctx context.Context) (*big.Int, error)

GetAvgGasPrice get default gas price from the pool.

func (*Default) UpdateGasPriceAvg

func (d *Default) UpdateGasPriceAvg(newValue *big.Int)

UpdateGasPriceAvg not needed for default strategy.

type EstimatorType

type EstimatorType string

EstimatorType different gas estimator types.

const (
	// DefaultType default gas price from config is set.
	DefaultType EstimatorType = "default"
	// AllBatchesType calculate average gas used from all batches.
	AllBatchesType EstimatorType = "allbatches"
	// LastNBatchesType calculate average gas tip from last n batches.
	LastNBatchesType EstimatorType = "lastnbatches"
)

type LastNL2Blocks

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

LastNL2Blocks struct for gas price estimator last n l2 blocks.

func NewEstimatorLastNL2Blocks

func NewEstimatorLastNL2Blocks(cfg Config, state stateInterface) *LastNL2Blocks

NewEstimatorLastNL2Blocks init gas price estimator for last n l2 blocks strategy.

func (*LastNL2Blocks) GetAvgGasPrice

func (g *LastNL2Blocks) GetAvgGasPrice(ctx context.Context) (*big.Int, error)

GetAvgGasPrice calculate avg gas price from last n l2 blocks.

func (*LastNL2Blocks) UpdateGasPriceAvg

func (g *LastNL2Blocks) UpdateGasPriceAvg(newValue *big.Int)

UpdateGasPriceAvg for last n bathes strategy is not needed to implement this function.

Jump to

Keyboard shortcuts

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