Skip to content

Commit

Permalink
Fix getBlockTransactionCountByNumber/Hash (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
cffls authored Oct 29, 2024
1 parent ff29b1f commit ab66e61
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,8 @@ func NewTransactionAPI(b Backend, nonceLock *AddrLocker) *TransactionAPI {
// GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.
func (api *TransactionAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint {
if block, _ := api.b.BlockByNumber(ctx, blockNr); block != nil {
n := hexutil.Uint(len(block.Transactions()))
txs, _ := api.getAllBlockTransactions(ctx, block)
n := hexutil.Uint(len(txs))
return &n
}

Expand All @@ -1935,7 +1936,8 @@ func (api *TransactionAPI) GetBlockTransactionCountByNumber(ctx context.Context,
// GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.
func (api *TransactionAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint {
if block, _ := api.b.BlockByHash(ctx, blockHash); block != nil {
n := hexutil.Uint(len(block.Transactions()))
txs, _ := api.getAllBlockTransactions(ctx, block)
n := hexutil.Uint(len(txs))
return &n
}

Expand Down

0 comments on commit ab66e61

Please sign in to comment.