Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type CirculeQueue ¶
type CirculeQueue struct {
// contains filtered or unexported fields
}
CirculeQueue currently is only for special usage. Thread unsafe!
func NewCirculeQueue ¶
func NewCirculeQueue(c int) *CirculeQueue
func NewCirculeQueueByItems ¶
func NewCirculeQueueByItems(items []interface{}) *CirculeQueue
func (*CirculeQueue) EnAndReplace ¶
func (q *CirculeQueue) EnAndReplace(b interface{}) (d interface{})
EnAndReplace enqueue one price and return the replaced one, if there's no item replaced, the return will be nil.
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) FeeHistory ¶
func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error)
FeeHistory returns data relevant for fee estimation based on the specified range of blocks. The range can be specified either with absolute block numbers or ending with the latest or pending block. Backends may or may not support gathering data from the pending block or blocks older than a certain age (specified in maxHistory). The first block of the actually processed range is returned to avoid ambiguity when parts of the requested range are not available or when the head has changed during processing this request. Three arrays are returned based on the processed blocks:
- reward: the requested percentiles of effective priority fees per gas of transactions in each block, sorted in ascending order and weighted by gas used.
- baseFee: base fee per gas in the given block
- gasUsedRatio: gasUsed/gasLimit in the given block
Note: baseFee includes the next block after the newest of the returned range, because this value can be derived from the newest block.
func (*Oracle) SuggestTipCap ¶
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 ¶
type OracleBackend interface { HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) PendingBlockAndReceipts() (*types.Block, types.Receipts) ChainConfig() *params.ChainConfig SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription }
OracleBackend includes all necessary background APIs for oracle.
type PredConfig ¶
type PredConfig struct { PredictIntervalSecs int MinTxCntPerBlock int // minimum tx cnt per block for caculations. FastFactor int // how many times of avgTxCnt for the fast index MedianFactor int // how many times of avgTxCnt for the median index LowFactor int // how many times of avgTxCnt for the low index MinMedianIndex int // min index in all pending transactions for median price MinLowIndex int // min index in all pending transactions for low price FastPercentile int //fast percentile for the case there are no many pending transactions MeidanPercentile int MaxValidPendingSecs int }
type Prediction ¶
type Prediction struct {
// contains filtered or unexported fields
}
func NewPrediction ¶
func NewPrediction(cfg Config, backend OracleBackend, pool *core.TxPool) *Prediction
func (*Prediction) CurrentPrices ¶
func (p *Prediction) CurrentPrices() []uint
CurrentPrices returns the current prediction about gas price in gwei; the results should be readonly, and the reason didn't do a copy is that there's no necessary