Implements eth_getBlockTransactionCountByNumber (#88)

* Implements eth_getBlockTransactionCountByNumber

* Added error handling for getting block at height
This commit is contained in:
Austin Abell 2019-09-02 20:42:58 -04:00 committed by GitHub
parent f5dc62a30f
commit 9c0015678f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,8 +114,19 @@ func (e *PublicEthAPI) GetBlockTransactionCountByHash(hash common.Hash) hexutil.
}
// GetBlockTransactionCountByNumber returns the number of transactions in the block identified by number.
func (e *PublicEthAPI) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) hexutil.Uint {
return 0
func (e *PublicEthAPI) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) (hexutil.Uint, error) {
node, err := e.cliCtx.GetNode()
if err != nil {
return 0, err
}
height := blockNum.Int64()
block, err := node.Block(&height)
if err != nil {
return 0, err
}
return hexutil.Uint(block.Block.NumTxs), nil
}
// GetUncleCountByBlockHash returns the number of uncles in the block idenfied by hash. Always zero.