inline GetBlockTransactionCountByNumber

This commit is contained in:
Taylor Gerring 2015-03-19 20:30:42 -04:00
parent c57eb286d6
commit ff657edbb6
1 changed files with 3 additions and 11 deletions

View File

@ -361,12 +361,6 @@ func (p *EthereumApi) GetBlockTransactionCountByHash(blockhash string) (int64, e
return int64(len(br.Transactions)), nil return int64(len(br.Transactions)), nil
} }
func (p *EthereumApi) GetBlockTransactionCountByNumber(blocknum int64) (int64, error) {
block := p.xeth().EthBlockByNumber(blocknum)
br := NewBlockRes(block)
return int64(len(br.Transactions)), nil
}
func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error { func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error {
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC // Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
rpclogger.Debugf("%s %s", req.Method, req.Params) rpclogger.Debugf("%s %s", req.Method, req.Params)
@ -458,11 +452,9 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err return err
} }
v, err := p.GetBlockTransactionCountByNumber(args.BlockNumber) block := p.xeth().EthBlockByNumber(args.BlockNumber)
if err != nil { br := NewBlockRes(block)
return err *reply = common.ToHex(big.NewInt(int64(len(br.Transactions))).Bytes())
}
*reply = common.ToHex(big.NewInt(v).Bytes())
case "eth_getUncleCountByBlockHash": case "eth_getUncleCountByBlockHash":
args := new(GetBlockByHashArgs) args := new(GetBlockByHashArgs)
if err := json.Unmarshal(req.Params, &args); err != nil { if err := json.Unmarshal(req.Params, &args); err != nil {