@@ -64,6 +64,8 @@ import (
64
64
"github.com/ethereum/go-ethereum/rpc"
65
65
)
66
66
67
+ var maxPrice = big .NewInt (1200000 * params .GWei )
68
+
67
69
// Config contains the configuration options of the ETH protocol.
68
70
// Deprecated: use ethconfig.Config instead.
69
71
type Config = ethconfig.Config
@@ -226,7 +228,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
226
228
config .TxPool .Journal = stack .ResolvePath (config .TxPool .Journal )
227
229
}
228
230
//getCurrentGasPriceFunc
229
- eth .txPool = core .NewEnhanceTxPool (config .TxPool , chainConfig , eth .blockchain , getCurrentGasFreeAddressMapFunc (ethAPI ), getCurrentGasPriceFunc (ethAPI ))
231
+ eth .txPool = core .NewEnhanceTxPool (config .TxPool , chainConfig , eth .blockchain , getCurrentGasFreeAddressMapFunc (ethAPI ), getCurrentGasPriceFunc (eth , ethAPI ))
230
232
231
233
// Permit the downloader to use the trie cache allowance during fast sync
232
234
cacheLimit := cacheConfig .TrieCleanLimit + cacheConfig .TrieDirtyLimit + cacheConfig .SnapshotLimit
@@ -600,7 +602,7 @@ func (s *Ethereum) Stop() error {
600
602
601
603
return nil
602
604
}
603
- func getCurrentGasPriceFunc (ee * ethapi.PublicBlockChainAPI ) func (common.Hash ) (* big.Int , error ) {
605
+ func getCurrentGasPriceFunc (eth * Ethereum , ee * ethapi.PublicBlockChainAPI ) func (common.Hash ) (* big.Int , error ) {
604
606
return func (blockHash common.Hash ) (* big.Int , error ) {
605
607
// block
606
608
blockNr := rpc .BlockNumberOrHashWithHash (blockHash , false )
@@ -631,11 +633,24 @@ func getCurrentGasPriceFunc(ee *ethapi.PublicBlockChainAPI) func(common.Hash) (*
631
633
if err != nil {
632
634
return nil , err
633
635
}
634
- out := big .NewInt (0 )
635
- if err := chainConfig .UnpackIntoInterface (& out , method , result ); err != nil {
636
+ gasPrice := big .NewInt (0 )
637
+ if err := chainConfig .UnpackIntoInterface (& gasPrice , method , result ); err != nil {
636
638
return nil , err
637
639
}
638
- return out , nil
640
+ if gasPrice != nil && eth .APIBackend .gpo != nil && gasPrice .Cmp (common .Big0 ) > 0 {
641
+ if eth .APIBackend .gpo .GetDefaultPrice () == nil || eth .APIBackend .gpo .GetDefaultPrice ().Cmp (gasPrice ) != 0 {
642
+ eth .APIBackend .gpo .SetDefaultPrice (gasPrice )
643
+ }
644
+ if eth .APIBackend .gpo .GetMaxPrice () == nil || eth .APIBackend .gpo .GetMaxPrice ().Cmp (maxPrice ) != 0 {
645
+ eth .APIBackend .gpo .SetMaxPrice (maxPrice )
646
+ }
647
+ if eth .gasPrice == nil || eth .gasPrice .Cmp (gasPrice ) != 0 {
648
+ eth .lock .Lock ()
649
+ eth .gasPrice = gasPrice
650
+ eth .lock .Unlock ()
651
+ }
652
+ }
653
+ return gasPrice , nil
639
654
}
640
655
}
641
656
0 commit comments