Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
876ce0fb
Commit
876ce0fb
authored
Apr 02, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More nil checks
parent
172b3435
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
api.go
rpc/api.go
+6
-0
responses.go
rpc/responses.go
+4
-2
No files found.
rpc/api.go
View file @
876ce0fb
...
@@ -212,6 +212,9 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -212,6 +212,9 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
block
:=
api
.
xeth
()
.
EthBlockByHash
(
args
.
Hash
)
block
:=
api
.
xeth
()
.
EthBlockByHash
(
args
.
Hash
)
br
:=
NewBlockRes
(
block
,
true
)
br
:=
NewBlockRes
(
block
,
true
)
if
br
==
nil
{
*
reply
=
nil
}
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"
)
return
NewValidationError
(
"Index"
,
"does not exist"
)
...
@@ -225,6 +228,9 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -225,6 +228,9 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
block
:=
api
.
xeth
()
.
EthBlockByNumber
(
args
.
BlockNumber
)
block
:=
api
.
xeth
()
.
EthBlockByNumber
(
args
.
BlockNumber
)
v
:=
NewBlockRes
(
block
,
true
)
v
:=
NewBlockRes
(
block
,
true
)
if
v
==
nil
{
*
reply
=
nil
}
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"
)
return
NewValidationError
(
"Index"
,
"does not exist"
)
...
...
rpc/responses.go
View file @
876ce0fb
...
@@ -125,8 +125,6 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
...
@@ -125,8 +125,6 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
}
}
func
NewBlockRes
(
block
*
types
.
Block
,
fullTx
bool
)
*
BlockRes
{
func
NewBlockRes
(
block
*
types
.
Block
,
fullTx
bool
)
*
BlockRes
{
// TODO respect fullTx flag
if
block
==
nil
{
if
block
==
nil
{
return
nil
return
nil
}
}
...
@@ -182,6 +180,10 @@ type TransactionRes struct {
...
@@ -182,6 +180,10 @@ type TransactionRes struct {
}
}
func
NewTransactionRes
(
tx
*
types
.
Transaction
)
*
TransactionRes
{
func
NewTransactionRes
(
tx
*
types
.
Transaction
)
*
TransactionRes
{
if
tx
==
nil
{
return
nil
}
var
v
=
new
(
TransactionRes
)
var
v
=
new
(
TransactionRes
)
v
.
Hash
=
newHexData
(
tx
.
Hash
())
v
.
Hash
=
newHexData
(
tx
.
Hash
())
v
.
Nonce
=
newHexNum
(
tx
.
Nonce
())
v
.
Nonce
=
newHexNum
(
tx
.
Nonce
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment