@@ -85,6 +85,7 @@ type BlockChainAPI struct {
8585 blocks storage.BlockIndexer
8686 transactions storage.TransactionIndexer
8787 receipts storage.ReceiptIndexer
88+ feeParameters storage.FeeParametersIndexer
8889 indexingResumedHeight uint64
8990 rateLimiter RateLimiter
9091 collector metrics.Collector
@@ -97,6 +98,7 @@ func NewBlockChainAPI(
9798 blocks storage.BlockIndexer ,
9899 transactions storage.TransactionIndexer ,
99100 receipts storage.ReceiptIndexer ,
101+ feeParameters storage.FeeParametersIndexer ,
100102 rateLimiter RateLimiter ,
101103 collector metrics.Collector ,
102104 indexingResumedHeight uint64 ,
@@ -108,6 +110,7 @@ func NewBlockChainAPI(
108110 blocks : blocks ,
109111 transactions : transactions ,
110112 receipts : receipts ,
113+ feeParameters : feeParameters ,
111114 indexingResumedHeight : indexingResumedHeight ,
112115 rateLimiter : rateLimiter ,
113116 collector : collector ,
@@ -1007,7 +1010,16 @@ func (b *BlockChainAPI) Coinbase(ctx context.Context) (common.Address, error) {
10071010
10081011// GasPrice returns a suggestion for a gas price for legacy transactions.
10091012func (b * BlockChainAPI ) GasPrice (ctx context.Context ) (* hexutil.Big , error ) {
1010- return (* hexutil .Big )(b .config .GasPrice ), nil
1013+ feeParams , err := b .feeParameters .Get ()
1014+ if err != nil {
1015+ return nil , err
1016+ }
1017+
1018+ surgeFactor := uint64 (feeParams .SurgeFactor )
1019+ multiplier := new (big.Int ).Exp (big .NewInt (10 ), big .NewInt (int64 (8 )), nil )
1020+ gp := b .config .GasPrice .Uint64 ()
1021+ gasPrice := new (big.Int ).SetUint64 (uint64 (gp * surgeFactor ))
1022+ return (* hexutil .Big )(new (big.Int ).Div (gasPrice , multiplier )), nil
10111023}
10121024
10131025// GetUncleCountByBlockHash returns number of uncles in the block for the given block hash
0 commit comments