Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidPercentile = errors.New("invalid percentile") ErrBlockCount = errors.New("blockCount must be greater than 0") ErrBlockNotFound = errors.New("could not find block") )
View Source
var DefaultGasHelperConfig = &Config{ NumOfBlocksToCheck: 20, PricePercentile: 60, SampleNumber: 3, MaxPrice: ethgo.Gwei(10), LastPrice: ethgo.Gwei(0), IgnorePrice: big.NewInt(2), }
DefaultGasHelperConfig is the default config for gas helper (as per ethereum)
Functions ¶
This section is empty.
Types ¶
type Blockchain ¶
type Blockchain interface {
GetBlockByNumber(number uint64, full bool) (*types.Block, bool)
GetBlockByHash(hash types.Hash, full bool) (*types.Block, bool)
Header() *types.Header
Config() *chain.Params
}
Blockchain is the interface representing blockchain
type Config ¶
type Config struct {
// NumOfBlocksToCheck is the number of blocks to sample
NumOfBlocksToCheck uint64
// PricePercentile is the sample percentile of transactions in a block
PricePercentile uint64
// SampleNumber is number of transactions sampled in a block
SampleNumber uint64
// MaxPrice is the tip max price
MaxPrice *big.Int
// LastPrice is the last price returned for maxPriorityFeePerGas
// when starting node it will be some default value
LastPrice *big.Int
// IgnorePrice is the lowest price to take into consideration
// when collecting transactions
IgnorePrice *big.Int
}
Config is a struct that holds configuration of GasHelper
type FeeHistoryReturn ¶
type GasHelper ¶
type GasHelper struct {
// contains filtered or unexported fields
}
GasHelper struct implements functions from the GasStore interface
func NewGasHelper ¶
func NewGasHelper(config *Config, backend Blockchain) (*GasHelper, error)
NewGasHelper is the constructor function for GasHelper struct
func (*GasHelper) FeeHistory ¶
func (*GasHelper) MaxPriorityFeePerGas ¶
MaxPriorityFeePerGas calculates the priority fee needed for transaction to be included in a block The function does following:
- takes chain header
- iterates for numOfBlocksToCheck from chain header to previous blocks
- collects at most the sample number of sorted transactions in block
- if not enough transactions were collected and their tips, go through some more blocks to get more accurate calculation
- when enough transactions and their tips are collected, take the one that is in pricePercentile
- if given price is larger then maxPrice then return the maxPrice
type GasStore ¶
type GasStore interface {
// MaxPriorityFeePerGas calculates the priority fee needed for transaction to be included in a block
MaxPriorityFeePerGas() (*big.Int, error)
// FeeHistory returns the collection of historical gas information
FeeHistory(uint64, uint64, []float64) (*FeeHistoryReturn, error)
}
GasStore interface is providing functions regarding gas and fees
Click to show internal directories.
Click to hide internal directories.