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
64933321
Commit
64933321
authored
Mar 11, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rpcfrontier' of github.com-obscure:ethereum/go-ethereum into rpcfrontier
parents
7e0ccc9d
499f816e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
34 deletions
+64
-34
api.go
rpc/api.go
+1
-1
responses.go
rpc/responses.go
+33
-32
util.go
rpc/util.go
+5
-1
util_test.go
rpc/util_test.go
+25
-0
No files found.
rpc/api.go
View file @
64933321
...
...
@@ -459,7 +459,7 @@ func (p *EthereumApi) GetBlockUncleCountByNumber(blocknum int64) (int64, error)
func
(
p
*
EthereumApi
)
GetRequestReply
(
req
*
RpcRequest
,
reply
*
interface
{})
error
{
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
rpclogger
.
Info
f
(
"%s %s"
,
req
.
Method
,
req
.
Params
)
rpclogger
.
Debug
f
(
"%s %s"
,
req
.
Method
,
req
.
Params
)
switch
req
.
Method
{
case
"web3_sha3"
:
args
:=
new
(
Sha3Args
)
...
...
rpc/responses.go
View file @
64933321
...
...
@@ -5,7 +5,6 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
)
type
BlockRes
struct
{
...
...
@@ -56,23 +55,23 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
}
// convert strict types to hexified strings
ext
.
BlockNumber
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
b
.
BlockNumber
)
.
Bytes
())
ext
.
BlockHash
=
ethutil
.
Bytes2
Hex
(
b
.
BlockHash
)
ext
.
ParentHash
=
ethutil
.
Bytes2
Hex
(
b
.
ParentHash
)
ext
.
Nonce
=
ethutil
.
Bytes2
Hex
(
b
.
Nonce
)
ext
.
Sha3Uncles
=
ethutil
.
Bytes2
Hex
(
b
.
Sha3Uncles
)
ext
.
LogsBloom
=
ethutil
.
Bytes2
Hex
(
b
.
LogsBloom
)
ext
.
TransactionRoot
=
ethutil
.
Bytes2
Hex
(
b
.
TransactionRoot
)
ext
.
StateRoot
=
ethutil
.
Bytes2
Hex
(
b
.
StateRoot
)
ext
.
Miner
=
ethutil
.
Bytes2
Hex
(
b
.
Miner
)
ext
.
Difficulty
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
b
.
Difficulty
)
.
Bytes
())
ext
.
TotalDifficulty
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
b
.
TotalDifficulty
)
.
Bytes
())
ext
.
Size
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
b
.
Size
)
.
Bytes
())
ext
.
ExtraData
=
ethutil
.
Bytes2
Hex
(
b
.
ExtraData
)
ext
.
GasLimit
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
b
.
GasLimit
)
.
Bytes
())
ext
.
MinGasPrice
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
b
.
MinGasPrice
)
.
Bytes
())
ext
.
GasUsed
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
b
.
GasUsed
)
.
Bytes
())
ext
.
UnixTimestamp
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
b
.
UnixTimestamp
)
.
Bytes
())
ext
.
BlockNumber
=
to
Hex
(
big
.
NewInt
(
b
.
BlockNumber
)
.
Bytes
())
ext
.
BlockHash
=
to
Hex
(
b
.
BlockHash
)
ext
.
ParentHash
=
to
Hex
(
b
.
ParentHash
)
ext
.
Nonce
=
to
Hex
(
b
.
Nonce
)
ext
.
Sha3Uncles
=
to
Hex
(
b
.
Sha3Uncles
)
ext
.
LogsBloom
=
to
Hex
(
b
.
LogsBloom
)
ext
.
TransactionRoot
=
to
Hex
(
b
.
TransactionRoot
)
ext
.
StateRoot
=
to
Hex
(
b
.
StateRoot
)
ext
.
Miner
=
to
Hex
(
b
.
Miner
)
ext
.
Difficulty
=
to
Hex
(
big
.
NewInt
(
b
.
Difficulty
)
.
Bytes
())
ext
.
TotalDifficulty
=
to
Hex
(
big
.
NewInt
(
b
.
TotalDifficulty
)
.
Bytes
())
ext
.
Size
=
to
Hex
(
big
.
NewInt
(
b
.
Size
)
.
Bytes
())
// ext.ExtraData = to
Hex(b.ExtraData)
ext
.
GasLimit
=
to
Hex
(
big
.
NewInt
(
b
.
GasLimit
)
.
Bytes
())
// ext.MinGasPrice = to
Hex(big.NewInt(b.MinGasPrice).Bytes())
ext
.
GasUsed
=
to
Hex
(
big
.
NewInt
(
b
.
GasUsed
)
.
Bytes
())
ext
.
UnixTimestamp
=
to
Hex
(
big
.
NewInt
(
b
.
UnixTimestamp
)
.
Bytes
())
ext
.
Transactions
=
make
([]
interface
{},
len
(
b
.
Transactions
))
if
b
.
fullTx
{
for
i
,
tx
:=
range
b
.
Transactions
{
...
...
@@ -80,12 +79,12 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
}
}
else
{
for
i
,
tx
:=
range
b
.
Transactions
{
ext
.
Transactions
[
i
]
=
ethutil
.
Bytes2
Hex
(
tx
.
Hash
)
ext
.
Transactions
[
i
]
=
to
Hex
(
tx
.
Hash
)
}
}
ext
.
Uncles
=
make
([]
string
,
len
(
b
.
Uncles
))
for
i
,
v
:=
range
b
.
Uncles
{
ext
.
Uncles
[
i
]
=
ethutil
.
Bytes2
Hex
(
v
)
ext
.
Uncles
[
i
]
=
to
Hex
(
v
)
}
return
json
.
Marshal
(
ext
)
...
...
@@ -103,7 +102,9 @@ func NewBlockRes(block *types.Block) *BlockRes {
res
.
StateRoot
=
block
.
Root
()
res
.
Miner
=
block
.
Header
()
.
Coinbase
res
.
Difficulty
=
block
.
Difficulty
()
.
Int64
()
if
block
.
Td
!=
nil
{
res
.
TotalDifficulty
=
block
.
Td
.
Int64
()
}
res
.
Size
=
int64
(
block
.
Size
())
// res.ExtraData =
res
.
GasLimit
=
block
.
GasLimit
()
.
Int64
()
...
...
@@ -154,17 +155,17 @@ func (t *TransactionRes) MarshalJSON() ([]byte, error) {
Input
string
`json:"input"`
}
ext
.
Hash
=
ethutil
.
Bytes2
Hex
(
t
.
Hash
)
ext
.
Nonce
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
t
.
Nonce
)
.
Bytes
())
ext
.
BlockHash
=
ethutil
.
Bytes2
Hex
(
t
.
BlockHash
)
ext
.
BlockNumber
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
t
.
BlockNumber
)
.
Bytes
())
ext
.
TxIndex
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
t
.
TxIndex
)
.
Bytes
())
ext
.
From
=
ethutil
.
Bytes2
Hex
(
t
.
From
)
ext
.
To
=
ethutil
.
Bytes2
Hex
(
t
.
To
)
ext
.
Value
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
t
.
Value
)
.
Bytes
())
ext
.
Gas
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
t
.
Gas
)
.
Bytes
())
ext
.
GasPrice
=
ethutil
.
Bytes2
Hex
(
big
.
NewInt
(
t
.
GasPrice
)
.
Bytes
())
ext
.
Input
=
ethutil
.
Bytes2
Hex
(
t
.
Input
)
ext
.
Hash
=
to
Hex
(
t
.
Hash
)
ext
.
Nonce
=
to
Hex
(
big
.
NewInt
(
t
.
Nonce
)
.
Bytes
())
ext
.
BlockHash
=
to
Hex
(
t
.
BlockHash
)
ext
.
BlockNumber
=
to
Hex
(
big
.
NewInt
(
t
.
BlockNumber
)
.
Bytes
())
ext
.
TxIndex
=
to
Hex
(
big
.
NewInt
(
t
.
TxIndex
)
.
Bytes
())
ext
.
From
=
to
Hex
(
t
.
From
)
ext
.
To
=
to
Hex
(
t
.
To
)
ext
.
Value
=
to
Hex
(
big
.
NewInt
(
t
.
Value
)
.
Bytes
())
ext
.
Gas
=
to
Hex
(
big
.
NewInt
(
t
.
Gas
)
.
Bytes
())
ext
.
GasPrice
=
to
Hex
(
big
.
NewInt
(
t
.
GasPrice
)
.
Bytes
())
ext
.
Input
=
to
Hex
(
t
.
Input
)
return
json
.
Marshal
(
ext
)
}
...
...
rpc/util.go
View file @
64933321
...
...
@@ -91,7 +91,7 @@ func UnmarshalRawMessages(b []byte, iface interface{}, number *int64) (err error
func
(
self
JsonWrapper
)
Send
(
writer
io
.
Writer
,
v
interface
{})
(
n
int
,
err
error
)
{
var
payload
[]
byte
payload
,
err
=
json
.
Marshal
(
v
)
payload
,
err
=
json
.
Marshal
Indent
(
v
,
""
,
"
\t
"
)
if
err
!=
nil
{
rpclogger
.
Fatalln
(
"Error marshalling JSON"
,
err
)
return
0
,
err
...
...
@@ -127,11 +127,15 @@ func toHex(b []byte) string {
}
return
"0x"
+
hex
}
func
fromHex
(
s
string
)
[]
byte
{
if
len
(
s
)
>
1
{
if
s
[
0
:
2
]
==
"0x"
{
s
=
s
[
2
:
]
}
if
len
(
s
)
%
2
==
1
{
s
=
"0"
+
s
}
return
ethutil
.
Hex2Bytes
(
s
)
}
return
nil
...
...
rpc/util_test.go
0 → 100644
View file @
64933321
package
rpc
import
(
"bytes"
"testing"
)
//fromHex
func
TestFromHex
(
t
*
testing
.
T
)
{
input
:=
"0x01"
expected
:=
[]
byte
{
1
}
result
:=
fromHex
(
input
)
if
bytes
.
Compare
(
expected
,
result
)
!=
0
{
t
.
Errorf
(
"Expected % x got % x"
,
expected
,
result
)
}
}
func
TestFromHexOddLength
(
t
*
testing
.
T
)
{
input
:=
"0x1"
expected
:=
[]
byte
{
1
}
result
:=
fromHex
(
input
)
if
bytes
.
Compare
(
expected
,
result
)
!=
0
{
t
.
Errorf
(
"Expected % x got % x"
,
expected
,
result
)
}
}
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