diff options
Diffstat (limited to 'eth/gasprice')
-rw-r--r-- | eth/gasprice/gasprice.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index 33810b2..dc62ad6 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -48,12 +48,12 @@ type OracleBackend interface { // Oracle recommends gas prices based on the content of recent // blocks. Suitable for both light and full clients. type Oracle struct { - backend OracleBackend - lastHead common.Hash - lastPrice *big.Int - maxPrice *big.Int - cacheLock sync.RWMutex - fetchLock sync.Mutex + backend OracleBackend + lastHead common.Hash + minGasPrice *big.Int + maxPrice *big.Int + cacheLock sync.RWMutex + fetchLock sync.Mutex checkBlocks int percentile int @@ -83,7 +83,7 @@ func NewOracle(backend OracleBackend, params Config) *Oracle { } return &Oracle{ backend: backend, - lastPrice: params.Default, + minGasPrice: params.Default, maxPrice: maxPrice, checkBlocks: blocks, percentile: percent, @@ -93,7 +93,12 @@ func NewOracle(backend OracleBackend, params Config) *Oracle { // SuggestPrice returns a gasprice so that newly created transaction can // have a very high chance to be included in the following blocks. func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) { - return params.MinGasPrice, nil + return gpo.minGasPrice, nil +} + +// SetGasPrice sets the minimum gas price to [newGasPrice] +func (gpo *Oracle) SetGasPrice(newGasPrice *big.Int) { + gpo.minGasPrice = newGasPrice } type getBlockPricesResult struct { |