forked from cerc-io/plugeth
inline GetBlockUncleCountByHash
This commit is contained in:
parent
216175c265
commit
c57eb286d6
14
rpc/api.go
14
rpc/api.go
@ -367,12 +367,6 @@ func (p *EthereumApi) GetBlockTransactionCountByNumber(blocknum int64) (int64, e
|
|||||||
return int64(len(br.Transactions)), nil
|
return int64(len(br.Transactions)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *EthereumApi) GetBlockUncleCountByHash(blockhash string) (int64, error) {
|
|
||||||
block := p.xeth().EthBlockByHash(blockhash)
|
|
||||||
br := NewBlockRes(block)
|
|
||||||
return int64(len(br.Uncles)), 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)
|
||||||
@ -475,11 +469,9 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := p.GetBlockUncleCountByHash(args.BlockHash)
|
block := p.xeth().EthBlockByHash(args.BlockHash)
|
||||||
if err != nil {
|
br := NewBlockRes(block)
|
||||||
return err
|
*reply = common.ToHex(big.NewInt(int64(len(br.Uncles))).Bytes())
|
||||||
}
|
|
||||||
*reply = common.ToHex(big.NewInt(v).Bytes())
|
|
||||||
case "eth_getUncleCountByBlockNumber":
|
case "eth_getUncleCountByBlockNumber":
|
||||||
args := new(GetBlockByNumberArgs)
|
args := new(GetBlockByNumberArgs)
|
||||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user