gasprice

package
v4.0.0-...-e7c9483 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Deprecated: use DefaultFn
	Default         = new(big.Int).SetUint64(2 * params.Shannon)
	DefaultMaxPrice = big.NewInt(500000 * params.Shannon)
)

Functions

func DefaultFn

func DefaultFn(config *params.ChainConfig) func(*big.Int) *big.Int

DefaultFn returns a function to return the default gas price at a given block.

Types

type Config

type Config struct {
	Blocks     int
	Percentile int
	Default    *big.Int `toml:",omitempty"` // nil for default/dynamic
	MaxPrice   *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, params Config) *Oracle

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

func (*Oracle) SuggestPrice

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

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

type OracleBackend

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
}

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