aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-04-03 02:37:51 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-04-03 02:37:51 +0800
commit3e042317adc99438d6ffde0cbde4f0b40ad579c1 (patch)
tree21621d79eb7d1bb44743ad87fe1a7ef7268a780f /rpc
parent1d74086b4240f61d73e8fbf446f6234ab914ddce (diff)
downloaddexon-3e042317adc99438d6ffde0cbde4f0b40ad579c1.tar
dexon-3e042317adc99438d6ffde0cbde4f0b40ad579c1.tar.gz
dexon-3e042317adc99438d6ffde0cbde4f0b40ad579c1.tar.bz2
dexon-3e042317adc99438d6ffde0cbde4f0b40ad579c1.tar.lz
dexon-3e042317adc99438d6ffde0cbde4f0b40ad579c1.tar.xz
dexon-3e042317adc99438d6ffde0cbde4f0b40ad579c1.tar.zst
dexon-3e042317adc99438d6ffde0cbde4f0b40ad579c1.zip
Return nil if block does not exist
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/rpc/api.go b/rpc/api.go
index b8207ea0d..573f689a2 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -2,6 +2,7 @@ package rpc
import (
"encoding/json"
+ // "fmt"
"math/big"
"sync"
@@ -112,7 +113,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
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":
args := new(BlockNumArg)
if err := json.Unmarshal(req.Params, &args); err != nil {