Skip to content

Commit ab66e61

Browse files
authored
Fix getBlockTransactionCountByNumber/Hash (ethereum#1365)
1 parent ff29b1f commit ab66e61

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/ethapi/api.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,8 @@ func NewTransactionAPI(b Backend, nonceLock *AddrLocker) *TransactionAPI {
19251925
// GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.
19261926
func (api *TransactionAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint {
19271927
if block, _ := api.b.BlockByNumber(ctx, blockNr); block != nil {
1928-
n := hexutil.Uint(len(block.Transactions()))
1928+
txs, _ := api.getAllBlockTransactions(ctx, block)
1929+
n := hexutil.Uint(len(txs))
19291930
return &n
19301931
}
19311932

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

0 commit comments

Comments
 (0)