fix(api): change gas_price to use pending block (#1082)

* fix(api): change gas_price to use pending block
This commit is contained in:
Morty 2024-10-29 16:07:33 +08:00 committed by GitHub
parent c88cc480b0
commit 9fff27e4f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -68,8 +68,9 @@ func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)
if err != nil {
return nil, err
}
if head := s.b.CurrentHeader(); head.BaseFee != nil {
tipcap.Add(tipcap, head.BaseFee)
pendingBlock, _ := s.b.PendingBlockAndReceipts()
if pendingBlock != nil && pendingBlock.BaseFee() != nil {
tipcap.Add(tipcap, pendingBlock.BaseFee())
}
return (*hexutil.Big)(tipcap), err
}

View file

@ -63,6 +63,7 @@ type Backend interface {
BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)
PendingBlockAndReceipts() (*types.Block, types.Receipts)
StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error)
StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
StateAt(root common.Hash) (*state.StateDB, error)

View file

@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 7 // Minor version component of the current release
VersionPatch = 24 // Patch version component of the current release
VersionPatch = 25 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)