aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-04-02 22:12:19 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-04-02 22:12:19 +0800
commit537e2cfeb64a14d9c54d5ae69e02a866b5117bd3 (patch)
tree1d33a9364a30c7215b13f95e3e0dba565f2854f4 /rpc
parente882ba0c29a4e616113a4c16e6ea08b8a8abf06b (diff)
downloadgo-tangerine-537e2cfeb64a14d9c54d5ae69e02a866b5117bd3.tar.gz
go-tangerine-537e2cfeb64a14d9c54d5ae69e02a866b5117bd3.tar.zst
go-tangerine-537e2cfeb64a14d9c54d5ae69e02a866b5117bd3.zip
Return nil when requested uncle index is not valid
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 4ce2a98e2..872290eef 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -253,13 +253,13 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
if args.Index >= int64(len(br.Uncles)) || args.Index < 0 {
- return NewValidationError("Index", "does not exist")
+ // return NewValidationError("Index", "does not exist")
+ *reply = nil
+ } else {
+ uhash := br.Uncles[args.Index]
+ uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.String()), true)
+ *reply = uncle
}
-
- uhash := br.Uncles[args.Index]
- uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.String()), false)
-
- *reply = uncle
case "eth_getUncleByBlockNumberAndIndex":
args := new(BlockNumIndexArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -275,13 +275,13 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
if args.Index >= int64(len(v.Uncles)) || args.Index < 0 {
- return NewValidationError("Index", "does not exist")
+ // return NewValidationError("Index", "does not exist")
+ *reply = nil
+ } else {
+ uhash := v.Uncles[args.Index]
+ uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.String()), false)
+ *reply = uncle
}
-
- uhash := v.Uncles[args.Index]
- uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.String()), false)
-
- *reply = uncle
case "eth_getCompilers":
c := []string{""}
*reply = c