diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-04-02 22:11:00 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-04-02 22:11:00 +0800 |
commit | e882ba0c29a4e616113a4c16e6ea08b8a8abf06b (patch) | |
tree | 6143ab59992ba6fa3f7137c09f56c6522c59c186 | |
parent | aa71e27a3b0f42b980082c52232c68fb50a45052 (diff) | |
download | dexon-e882ba0c29a4e616113a4c16e6ea08b8a8abf06b.tar dexon-e882ba0c29a4e616113a4c16e6ea08b8a8abf06b.tar.gz dexon-e882ba0c29a4e616113a4c16e6ea08b8a8abf06b.tar.bz2 dexon-e882ba0c29a4e616113a4c16e6ea08b8a8abf06b.tar.lz dexon-e882ba0c29a4e616113a4c16e6ea08b8a8abf06b.tar.xz dexon-e882ba0c29a4e616113a4c16e6ea08b8a8abf06b.tar.zst dexon-e882ba0c29a4e616113a4c16e6ea08b8a8abf06b.zip |
Return nil when requested index does not exist
Instead of error
-rw-r--r-- | rpc/api.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/rpc/api.go b/rpc/api.go index b46151cda..4ce2a98e2 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -217,9 +217,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err } if args.Index >= int64(len(br.Transactions)) || args.Index < 0 { - return NewValidationError("Index", "does not exist") + // return NewValidationError("Index", "does not exist") + *reply = nil + } else { + *reply = br.Transactions[args.Index] } - *reply = br.Transactions[args.Index] case "eth_getTransactionByBlockNumberAndIndex": args := new(BlockNumIndexArgs) if err := json.Unmarshal(req.Params, &args); err != nil { @@ -233,9 +235,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err } if args.Index >= int64(len(v.Transactions)) || args.Index < 0 { - return NewValidationError("Index", "does not exist") + // return NewValidationError("Index", "does not exist") + *reply = nil + } else { + *reply = v.Transactions[args.Index] } - *reply = v.Transactions[args.Index] case "eth_getUncleByBlockHashAndIndex": args := new(HashIndexArgs) if err := json.Unmarshal(req.Params, &args); err != nil { |