From ab66e6173717779355b984a3db5a7e3a802b58d1 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 29 Oct 2024 11:45:56 -0700 Subject: [PATCH] Fix getBlockTransactionCountByNumber/Hash (#1365) --- internal/ethapi/api.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 28106be05e..a469a8c0e0 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -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 } @@ -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 }