|
|
@ -45,7 +45,6 @@ type Config struct { |
|
|
|
Percentile int |
|
|
|
Percentile int |
|
|
|
MaxHeaderHistory uint64 |
|
|
|
MaxHeaderHistory uint64 |
|
|
|
MaxBlockHistory uint64 |
|
|
|
MaxBlockHistory uint64 |
|
|
|
Default *big.Int `toml:",omitempty"` |
|
|
|
|
|
|
|
MaxPrice *big.Int `toml:",omitempty"` |
|
|
|
MaxPrice *big.Int `toml:",omitempty"` |
|
|
|
IgnorePrice *big.Int `toml:",omitempty"` |
|
|
|
IgnorePrice *big.Int `toml:",omitempty"` |
|
|
|
} |
|
|
|
} |
|
|
@ -79,7 +78,7 @@ type Oracle struct { |
|
|
|
|
|
|
|
|
|
|
|
// NewOracle returns a new gasprice oracle which can recommend suitable
|
|
|
|
// NewOracle returns a new gasprice oracle which can recommend suitable
|
|
|
|
// gasprice for newly created transaction.
|
|
|
|
// gasprice for newly created transaction.
|
|
|
|
func NewOracle(backend OracleBackend, params Config) *Oracle { |
|
|
|
func NewOracle(backend OracleBackend, params Config, startPrice *big.Int) *Oracle { |
|
|
|
blocks := params.Blocks |
|
|
|
blocks := params.Blocks |
|
|
|
if blocks < 1 { |
|
|
|
if blocks < 1 { |
|
|
|
blocks = 1 |
|
|
|
blocks = 1 |
|
|
@ -115,6 +114,9 @@ func NewOracle(backend OracleBackend, params Config) *Oracle { |
|
|
|
maxBlockHistory = 1 |
|
|
|
maxBlockHistory = 1 |
|
|
|
log.Warn("Sanitizing invalid gasprice oracle max block history", "provided", params.MaxBlockHistory, "updated", maxBlockHistory) |
|
|
|
log.Warn("Sanitizing invalid gasprice oracle max block history", "provided", params.MaxBlockHistory, "updated", maxBlockHistory) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if startPrice == nil { |
|
|
|
|
|
|
|
startPrice = new(big.Int) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cache := lru.NewCache[cacheKey, processedFees](2048) |
|
|
|
cache := lru.NewCache[cacheKey, processedFees](2048) |
|
|
|
headEvent := make(chan core.ChainHeadEvent, 1) |
|
|
|
headEvent := make(chan core.ChainHeadEvent, 1) |
|
|
@ -131,7 +133,7 @@ func NewOracle(backend OracleBackend, params Config) *Oracle { |
|
|
|
|
|
|
|
|
|
|
|
return &Oracle{ |
|
|
|
return &Oracle{ |
|
|
|
backend: backend, |
|
|
|
backend: backend, |
|
|
|
lastPrice: params.Default, |
|
|
|
lastPrice: startPrice, |
|
|
|
maxPrice: maxPrice, |
|
|
|
maxPrice: maxPrice, |
|
|
|
ignorePrice: ignorePrice, |
|
|
|
ignorePrice: ignorePrice, |
|
|
|
checkBlocks: blocks, |
|
|
|
checkBlocks: blocks, |
|
|
|