Skip to content

Commit

Permalink
Index is zero-based ethereum#607
Browse files Browse the repository at this point in the history
  • Loading branch information
tgerring committed Mar 31, 2015
1 parent 81aeb78 commit 8f0e095
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
br := NewBlockRes(block)
br.fullTx = true

if args.Index > int64(len(br.Transactions)) || args.Index < 0 {
if args.Index >= int64(len(br.Transactions)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}
*reply = br.Transactions[args.Index]
Expand All @@ -227,7 +227,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
v := NewBlockRes(block)
v.fullTx = true

if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
if args.Index >= int64(len(v.Transactions)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}
*reply = v.Transactions[args.Index]
Expand All @@ -239,7 +239,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err

br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash))

if args.Index > int64(len(br.Uncles)) || args.Index < 0 {
if args.Index >= int64(len(br.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}

Expand All @@ -257,7 +257,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
v := NewBlockRes(block)
v.fullTx = true

if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
if args.Index >= int64(len(v.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}

Expand Down

0 comments on commit 8f0e095

Please sign in to comment.