gasprice

package
v0.7.0-rc.12 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: LGPL-3.0 Imports: 11 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultMaxPrice   = big.NewInt(150 * params.GWei)
	DefaultMinPrice   = big.NewInt(0 * params.GWei)
	DefaultMinGasUsed = big.NewInt(2_000_000) // block gas limit is 8,000,000
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Blocks     int
	Percentile int
	MaxPrice   *big.Int `toml:",omitempty"`
	MinPrice   *big.Int `toml:",omitempty"`
	MinGasUsed *big.Int `toml:",omitempty"`
}

type Oracle

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

Oracle recommends gas prices based on the content of recent blocks. Suitable for both light and full clients.

func NewOracle

func NewOracle(backend OracleBackend, config Config) *Oracle

NewOracle returns a new gasprice oracle which can recommend suitable gasprice for newly created transaction.

func (*Oracle) EstimateBaseFee added in v0.6.0

func (oracle *Oracle) EstimateBaseFee(ctx context.Context) (*big.Int, error)

EstiamteBaseFee returns an estimate of what the base fee will be on a block produced at the current time. If ApricotPhase3 has not been activated, it may return a nil value and a nil error.

func (*Oracle) SuggestPrice

func (oracle *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error)

SuggestPrice returns an estimated price for legacy transactions.

func (*Oracle) SuggestTipCap added in v0.6.0

func (oracle *Oracle) SuggestTipCap(ctx context.Context) (*big.Int, error)

SuggestTipCap returns a tip cap so that newly created transaction can have a very high chance to be included in the following blocks.

Note, for legacy transactions and the legacy eth_gasPrice RPC call, it will be necessary to add the basefee to the returned number to fall back to the legacy behavior.

type OracleBackend added in v0.3.1

type OracleBackend interface {
	HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
	BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
	ChainConfig() *params.ChainConfig
	MinRequiredTip(ctx context.Context, header *types.Header) (*big.Int, error)
}

OracleBackend includes all necessary background APIs for oracle.

Jump to

Keyboard shortcuts

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