Skip to content

Commit

Permalink
fix(api): change gas_price to use pending block (#1082)
Browse files Browse the repository at this point in the history
* fix(api): change gas_price to use pending block
  • Loading branch information
yiweichi authored and 0xmountaintop committed Oct 30, 2024
1 parent 69ce8d9 commit 3747296
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ func (s *EthereumAPI) 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
}
Expand Down
1 change: 1 addition & 0 deletions internal/ethapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 66 in internal/ethapi/backend.go

View workflow job for this annotation

GitHub Actions / build-mock-ccc-geth

other declaration of PendingBlockAndReceipts

Check failure on line 66 in internal/ethapi/backend.go

View workflow job for this annotation

GitHub Actions / test

other declaration of PendingBlockAndReceipts
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)
Expand Down

0 comments on commit 3747296

Please sign in to comment.