aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-04-02 19:27:58 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-04-02 19:27:58 +0800
commitb86450aaae361ef183928b2de53e3724d3e174a8 (patch)
tree2e22cd47e079f21d4fa21f47e6754a642e76a9b6 /rpc
parente402e1dc2e72df2a433b984caeaba771085b2b66 (diff)
downloaddexon-b86450aaae361ef183928b2de53e3724d3e174a8.tar.gz
dexon-b86450aaae361ef183928b2de53e3724d3e174a8.tar.zst
dexon-b86450aaae361ef183928b2de53e3724d3e174a8.zip
Guard from nil pointers
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 478ca8752..20299bef1 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -238,6 +238,10 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash), false)
+ if br == nil {
+ *reply = nil
+ return nil
+ }
if args.Index >= int64(len(br.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
@@ -256,6 +260,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
block := api.xeth().EthBlockByNumber(args.BlockNumber)
v := NewBlockRes(block, true)
+ if v == nil {
+ *reply = nil
+ return nil
+ }
+
if args.Index >= int64(len(v.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}