Commit 3e042317 authored by Taylor Gerring's avatar Taylor Gerring

Return nil if block does not exist

parent 1d74086b
...@@ -2,6 +2,7 @@ package rpc ...@@ -2,6 +2,7 @@ package rpc
import ( import (
"encoding/json" "encoding/json"
// "fmt"
"math/big" "math/big"
"sync" "sync"
...@@ -112,7 +113,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err ...@@ -112,7 +113,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
} }
block := NewBlockRes(api.xeth().EthBlockByHash(args.Hash), false) block := NewBlockRes(api.xeth().EthBlockByHash(args.Hash), false)
*reply = common.ToHex(big.NewInt(int64(len(block.Transactions))).Bytes()) if block == nil {
*reply = nil
} else {
*reply = common.ToHex(big.NewInt(int64(len(block.Transactions))).Bytes())
}
case "eth_getBlockTransactionCountByNumber": case "eth_getBlockTransactionCountByNumber":
args := new(BlockNumArg) args := new(BlockNumArg)
if err := json.Unmarshal(req.Params, &args); err != nil { if err := json.Unmarshal(req.Params, &args); err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment