Skip to content

Commit a87842c

Browse files
author
eric
committed
set max gas price
1 parent a34823f commit a87842c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

eth/backend.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ import (
6464
"github.com/ethereum/go-ethereum/rpc"
6565
)
6666

67+
var maxPrice = big.NewInt(1200000 * params.GWei)
68+
6769
// Config contains the configuration options of the ETH protocol.
6870
// Deprecated: use ethconfig.Config instead.
6971
type Config = ethconfig.Config
@@ -639,6 +641,9 @@ func getCurrentGasPriceFunc(eth *Ethereum, ee *ethapi.PublicBlockChainAPI) func(
639641
if eth.APIBackend.gpo.GetDefaultPrice() == nil || eth.APIBackend.gpo.GetDefaultPrice().Cmp(gasPrice) != 0 {
640642
eth.APIBackend.gpo.SetDefaultPrice(gasPrice)
641643
}
644+
if eth.APIBackend.gpo.GetMaxPrice() == nil || eth.APIBackend.gpo.GetMaxPrice().Cmp(maxPrice) != 0 {
645+
eth.APIBackend.gpo.SetMaxPrice(maxPrice)
646+
}
642647
}
643648
return gasPrice, nil
644649
}

eth/gasprice/gasprice.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ func (gpo *Oracle) GetDefaultPrice() *big.Int {
105105
return gpo.defaultPrice
106106
}
107107

108+
func (gpo *Oracle) SetMaxPrice(maxPrice *big.Int) {
109+
gpo.maxPrice = maxPrice
110+
}
111+
func (gpo *Oracle) GetMaxPrice() *big.Int {
112+
return gpo.maxPrice
113+
}
114+
108115
// SuggestPrice returns a gasprice so that newly created transaction can
109116
// have a very high chance to be included in the following blocks.
110117
func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {

0 commit comments

Comments
 (0)