gasprice

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Defaults = Config{
		Blocks:      30,
		Percentile:  60,
		MaxPrice:    defaultMaxPrice,
		IgnorePrice: defaultIgnorePrice,
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Blocks      int
	Percentile  int
	Default     *big.Int `toml:",omitempty"`
	MaxPrice    *big.Int `toml:",omitempty"`
	IgnorePrice *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, error)

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

func (*Oracle) SuggestTipCap

func (oracle *Oracle) SuggestTipCap() (*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.

type OracleBackend

type OracleBackend interface {
	Header() *types.Header
	GetBlockByNumber(n uint64, full bool) (*types.Block, bool)
	GetReceiptsByHash(hash types.Hash) ([]*types.Receipt, error)
	// PendingBlockAndReceipts() (*types.Block, types.Receipts)
	ChainID() uint64
	ForksInTime(number uint64) chain.ForksInTime
	SubscribeEvents() blockchain.Subscription
}

OracleBackend includes most necessary background APIs for oracle.

Jump to

Keyboard shortcuts

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