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
21becb0f
Commit
21becb0f
authored
Feb 24, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup RPC packcage
parent
5a43173e
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
131 deletions
+90
-131
args.go
rpc/args.go
+18
-48
message.go
rpc/message.go
+70
-80
packages.go
rpc/packages.go
+2
-3
No files found.
rpc/args.go
View file @
21becb0f
...
@@ -19,7 +19,7 @@ func (obj *GetBlockArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -19,7 +19,7 @@ func (obj *GetBlockArgs) UnmarshalJSON(b []byte) (err error) {
obj
.
Hash
=
argstr
obj
.
Hash
=
argstr
return
return
}
}
return
NewErrorResponse
(
ErrorDecodeArgs
)
return
errDecodeArgs
}
}
type
NewTxArgs
struct
{
type
NewTxArgs
struct
{
...
@@ -57,7 +57,7 @@ func (obj *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -57,7 +57,7 @@ func (obj *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
return
return
}
}
return
NewErrorResponse
(
ErrorDecodeArgs
)
return
errDecodeArgs
}
}
type
PushTxArgs
struct
{
type
PushTxArgs
struct
{
...
@@ -70,12 +70,12 @@ func (obj *PushTxArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -70,12 +70,12 @@ func (obj *PushTxArgs) UnmarshalJSON(b []byte) (err error) {
obj
.
Tx
=
arg0
obj
.
Tx
=
arg0
return
return
}
}
return
NewErrorResponse
(
ErrorDecodeArgs
)
return
errDecodeArgs
}
}
func
(
a
*
PushTxArgs
)
requirementsPushTx
()
error
{
func
(
a
*
PushTxArgs
)
requirementsPushTx
()
error
{
if
a
.
Tx
==
""
{
if
a
.
Tx
==
""
{
return
NewError
Response
(
"PushTx requires a 'tx' as argument"
)
return
NewError
WithMessage
(
errArguments
,
"PushTx requires a 'tx' as argument"
)
}
}
return
nil
return
nil
}
}
...
@@ -86,14 +86,14 @@ type GetStorageArgs struct {
...
@@ -86,14 +86,14 @@ type GetStorageArgs struct {
func
(
obj
*
GetStorageArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
func
(
obj
*
GetStorageArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
if
err
=
json
.
Unmarshal
(
b
,
&
obj
.
Address
);
err
!=
nil
{
if
err
=
json
.
Unmarshal
(
b
,
&
obj
.
Address
);
err
!=
nil
{
return
NewErrorResponse
(
ErrorDecodeArgs
)
return
errDecodeArgs
}
}
return
return
}
}
func
(
a
*
GetStorageArgs
)
requirements
()
error
{
func
(
a
*
GetStorageArgs
)
requirements
()
error
{
if
len
(
a
.
Address
)
==
0
{
if
len
(
a
.
Address
)
==
0
{
return
NewError
Response
(
"GetStorageAt requires an 'address' value as argument"
)
return
NewError
WithMessage
(
errArguments
,
"GetStorageAt requires an 'address' value as argument"
)
}
}
return
nil
return
nil
}
}
...
@@ -109,64 +109,39 @@ func (obj *GetStateArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -109,64 +109,39 @@ func (obj *GetStateArgs) UnmarshalJSON(b []byte) (err error) {
obj
.
Address
=
arg0
obj
.
Address
=
arg0
return
return
}
}
return
NewErrorResponse
(
ErrorDecodeArgs
)
return
errDecodeArgs
}
}
func
(
a
*
GetStateArgs
)
requirements
()
error
{
func
(
a
*
GetStateArgs
)
requirements
()
error
{
if
a
.
Address
==
""
{
if
a
.
Address
==
""
{
return
NewError
Response
(
"GetStorageAt requires an 'address' value as argument"
)
return
NewError
WithMessage
(
errArguments
,
"GetStorageAt requires an 'address' value as argument"
)
}
}
if
a
.
Key
==
""
{
if
a
.
Key
==
""
{
return
NewError
Response
(
"GetStorageAt requires an 'key' value as argument"
)
return
NewError
WithMessage
(
errArguments
,
"GetStorageAt requires an 'key' value as argument"
)
}
}
return
nil
return
nil
}
}
type
GetStorageAtRes
struct
{
Key
string
`json:"key"`
Value
string
`json:"value"`
}
type
GetTxCountArgs
struct
{
type
GetTxCountArgs
struct
{
Address
string
`json:"address"`
Address
string
`json:"address"`
}
}
// type GetTxCountRes struct {
// Nonce int `json:"nonce"`
// }
func
(
obj
*
GetTxCountArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
func
(
obj
*
GetTxCountArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
arg0
:=
""
arg0
:=
""
if
err
=
json
.
Unmarshal
(
b
,
&
arg0
);
err
==
nil
{
if
err
=
json
.
Unmarshal
(
b
,
&
arg0
);
err
==
nil
{
obj
.
Address
=
arg0
obj
.
Address
=
arg0
return
return
}
}
return
NewErrorResponse
(
"Could not determine JSON parameters"
)
return
errDecodeArgs
}
}
func
(
a
*
GetTxCountArgs
)
requirements
()
error
{
func
(
a
*
GetTxCountArgs
)
requirements
()
error
{
if
a
.
Address
==
""
{
if
a
.
Address
==
""
{
return
NewError
Response
(
"GetTxCountAt requires an 'address' value as argument"
)
return
NewError
WithMessage
(
errArguments
,
"GetTxCountAt requires an 'address' value as argument"
)
}
}
return
nil
return
nil
}
}
// type GetPeerCountRes struct {
// PeerCount int `json:"peerCount"`
// }
// type GetListeningRes struct {
// IsListening bool `json:"isListening"`
// }
// type GetCoinbaseRes struct {
// Coinbase string `json:"coinbase"`
// }
// type GetMiningRes struct {
// IsMining bool `json:"isMining"`
// }
type
GetBalanceArgs
struct
{
type
GetBalanceArgs
struct
{
Address
string
Address
string
}
}
...
@@ -177,21 +152,16 @@ func (obj *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -177,21 +152,16 @@ func (obj *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
obj
.
Address
=
arg0
obj
.
Address
=
arg0
return
return
}
}
return
NewErrorResponse
(
"Could not determine JSON parameters"
)
return
errDecodeArgs
}
}
func
(
a
*
GetBalanceArgs
)
requirements
()
error
{
func
(
a
*
GetBalanceArgs
)
requirements
()
error
{
if
a
.
Address
==
""
{
if
a
.
Address
==
""
{
return
NewError
Response
(
"GetBalanceAt requires an 'address' value as argument"
)
return
NewError
WithMessage
(
errArguments
,
"GetBalanceAt requires an 'address' value as argument"
)
}
}
return
nil
return
nil
}
}
type
BalanceRes
struct
{
Balance
string
`json:"balance"`
Address
string
`json:"address"`
}
type
GetCodeAtArgs
struct
{
type
GetCodeAtArgs
struct
{
Address
string
Address
string
}
}
...
@@ -202,12 +172,12 @@ func (obj *GetCodeAtArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -202,12 +172,12 @@ func (obj *GetCodeAtArgs) UnmarshalJSON(b []byte) (err error) {
obj
.
Address
=
arg0
obj
.
Address
=
arg0
return
return
}
}
return
NewErrorResponse
(
ErrorDecodeArgs
)
return
errDecodeArgs
}
}
func
(
a
*
GetCodeAtArgs
)
requirements
()
error
{
func
(
a
*
GetCodeAtArgs
)
requirements
()
error
{
if
a
.
Address
==
""
{
if
a
.
Address
==
""
{
return
NewError
Response
(
"GetCodeAt requires an 'address' value as argument"
)
return
NewError
WithMessage
(
errArguments
,
"GetCodeAt requires an 'address' value as argument"
)
}
}
return
nil
return
nil
}
}
...
@@ -218,7 +188,7 @@ type Sha3Args struct {
...
@@ -218,7 +188,7 @@ type Sha3Args struct {
func
(
obj
*
Sha3Args
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
func
(
obj
*
Sha3Args
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
if
err
=
json
.
Unmarshal
(
b
,
&
obj
.
Data
);
err
!=
nil
{
if
err
=
json
.
Unmarshal
(
b
,
&
obj
.
Data
);
err
!=
nil
{
return
NewErrorResponse
(
ErrorDecodeArgs
)
return
errDecodeArgs
}
}
return
return
}
}
...
@@ -270,10 +240,10 @@ type DbArgs struct {
...
@@ -270,10 +240,10 @@ type DbArgs struct {
func
(
a
*
DbArgs
)
requirements
()
error
{
func
(
a
*
DbArgs
)
requirements
()
error
{
if
len
(
a
.
Database
)
==
0
{
if
len
(
a
.
Database
)
==
0
{
return
NewError
Response
(
"DbPutArgs requires an 'Database' value as argument"
)
return
NewError
WithMessage
(
errArguments
,
"DbPutArgs requires an 'Database' value as argument"
)
}
}
if
len
(
a
.
Key
)
==
0
{
if
len
(
a
.
Key
)
==
0
{
return
NewError
Response
(
"DbPutArgs requires an 'Key' value as argument"
)
return
NewError
WithMessage
(
errArguments
,
"DbPutArgs requires an 'Key' value as argument"
)
}
}
return
nil
return
nil
}
}
...
...
rpc/message.go
View file @
21becb0f
This diff is collapsed.
Click to expand it.
rpc/packages.go
View file @
21becb0f
...
@@ -9,7 +9,6 @@ For each request type, define the following:
...
@@ -9,7 +9,6 @@ For each request type, define the following:
package
rpc
package
rpc
import
(
import
(
"fmt"
"math/big"
"math/big"
"strings"
"strings"
"sync"
"sync"
...
@@ -410,7 +409,7 @@ func (p *EthereumApi) WhisperMessages(id int, reply *interface{}) error {
...
@@ -410,7 +409,7 @@ func (p *EthereumApi) WhisperMessages(id int, reply *interface{}) error {
}
}
func
(
p
*
EthereumApi
)
GetRequestReply
(
req
*
RpcRequest
,
reply
*
interface
{})
error
{
func
(
p
*
EthereumApi
)
GetRequestReply
(
req
*
RpcRequest
,
reply
*
interface
{})
error
{
// Spec at https://github.com/ethereum/wiki/wiki/Generic-ON-RPC
// Spec at https://github.com/ethereum/wiki/wiki/Generic-
JS
ON-RPC
rpclogger
.
DebugDetailf
(
"%T %s"
,
req
.
Params
,
req
.
Params
)
rpclogger
.
DebugDetailf
(
"%T %s"
,
req
.
Params
,
req
.
Params
)
switch
req
.
Method
{
switch
req
.
Method
{
case
"eth_coinbase"
:
case
"eth_coinbase"
:
...
@@ -595,7 +594,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -595,7 +594,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
}
return
p
.
WhisperMessages
(
args
,
reply
)
return
p
.
WhisperMessages
(
args
,
reply
)
default
:
default
:
return
NewError
Response
(
fmt
.
Sprintf
(
"%v %s"
,
ErrorNotImplemented
,
req
.
Method
)
)
return
NewError
WithMessage
(
errNotImplemented
,
req
.
Method
)
}
}
rpclogger
.
DebugDetailf
(
"Reply: %T %s"
,
reply
,
reply
)
rpclogger
.
DebugDetailf
(
"Reply: %T %s"
,
reply
,
reply
)
...
...
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