aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-29 21:03:39 +0800
committerobscuren <geffobscura@gmail.com>2015-03-29 21:03:39 +0800
commite1c6c01b4d598f9b7f7ee31326d25903084fc292 (patch)
tree99d7fa0c5b905df134b0b373316e4a08c17b29c7 /rpc
parentb7a0bc70313597ada37cc1a348bbd0d39696ec6e (diff)
parent391d79ef44ad2e76754ef8dfb5e9dfbdd5a69acd (diff)
downloadgo-tangerine-e1c6c01b4d598f9b7f7ee31326d25903084fc292.tar
go-tangerine-e1c6c01b4d598f9b7f7ee31326d25903084fc292.tar.gz
go-tangerine-e1c6c01b4d598f9b7f7ee31326d25903084fc292.tar.bz2
go-tangerine-e1c6c01b4d598f9b7f7ee31326d25903084fc292.tar.lz
go-tangerine-e1c6c01b4d598f9b7f7ee31326d25903084fc292.tar.xz
go-tangerine-e1c6c01b4d598f9b7f7ee31326d25903084fc292.tar.zst
go-tangerine-e1c6c01b4d598f9b7f7ee31326d25903084fc292.zip
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go3
-rw-r--r--rpc/args.go21
-rw-r--r--rpc/http.go2
-rw-r--r--rpc/responses.go8
4 files changed, 13 insertions, 21 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 78e464c99..502079177 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -13,7 +13,6 @@ import (
type EthereumApi struct {
eth *xeth.XEth
xethMu sync.RWMutex
- db common.Database
}
func NewEthereumApi(xeth *xeth.XEth) *EthereumApi {
@@ -99,7 +98,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
state := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address)
value := state.StorageString(args.Key)
- *reply = common.Bytes2Hex(value.Bytes())
+ *reply = common.ToHex(value.Bytes())
case "eth_getTransactionCount":
args := new(GetTxCountArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
diff --git a/rpc/args.go b/rpc/args.go
index a075f1a59..25a6c7a4f 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -1,9 +1,7 @@
package rpc
import (
- "bytes"
"encoding/json"
- // "errors"
"fmt"
"math/big"
@@ -105,8 +103,8 @@ type GetBlockByHashArgs struct {
func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
- r := bytes.NewReader(b)
- if err := json.NewDecoder(r).Decode(&obj); err != nil {
+
+ if err := json.Unmarshal(b, &obj); err != nil {
return NewDecodeParamError(err.Error())
}
@@ -134,8 +132,7 @@ type GetBlockByNumberArgs struct {
func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
- r := bytes.NewReader(b)
- if err := json.NewDecoder(r).Decode(&obj); err != nil {
+ if err := json.Unmarshal(b, &obj); err != nil {
return NewDecodeParamError(err.Error())
}
@@ -405,8 +402,7 @@ type BlockNumIndexArgs struct {
func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
- r := bytes.NewReader(b)
- if err := json.NewDecoder(r).Decode(&obj); err != nil {
+ if err := json.Unmarshal(b, &obj); err != nil {
return NewDecodeParamError(err.Error())
}
@@ -436,8 +432,7 @@ type HashIndexArgs struct {
func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
- r := bytes.NewReader(b)
- if err := json.NewDecoder(r).Decode(&obj); err != nil {
+ if err := json.Unmarshal(b, &obj); err != nil {
return NewDecodeParamError(err.Error())
}
@@ -468,8 +463,7 @@ type Sha3Args struct {
func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
- r := bytes.NewReader(b)
- if err := json.NewDecoder(r).Decode(&obj); err != nil {
+ if err := json.Unmarshal(b, &obj); err != nil {
return NewDecodeParamError(err.Error())
}
@@ -798,8 +792,7 @@ type FilterStringArgs struct {
func (args *FilterStringArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
- r := bytes.NewReader(b)
- if err := json.NewDecoder(r).Decode(&obj); err != nil {
+ if err := json.Unmarshal(b, &obj); err != nil {
return NewDecodeParamError(err.Error())
}
diff --git a/rpc/http.go b/rpc/http.go
index 879ffce3b..919c567bd 100644
--- a/rpc/http.go
+++ b/rpc/http.go
@@ -76,7 +76,7 @@ func RpcResponse(api *EthereumApi, request *RpcRequest) *interface{} {
case *NotImplementedError:
jsonerr := &RpcErrorObject{-32601, reserr.Error()}
response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr}
- case *DecodeParamError, *InsufficientParamsError, *ValidationError:
+ case *DecodeParamError, *InsufficientParamsError, *ValidationError, *InvalidTypeError:
jsonerr := &RpcErrorObject{-32602, reserr.Error()}
response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr}
default:
diff --git a/rpc/responses.go b/rpc/responses.go
index f5f3a33f3..9767cac3b 100644
--- a/rpc/responses.go
+++ b/rpc/responses.go
@@ -70,7 +70,7 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
ext.Difficulty = common.ToHex(b.Difficulty.Bytes())
ext.TotalDifficulty = common.ToHex(b.TotalDifficulty.Bytes())
ext.Size = common.ToHex(b.Size.Bytes())
- // ext.ExtraData = common.ToHex(b.ExtraData)
+ ext.ExtraData = common.ToHex(b.ExtraData)
ext.GasLimit = common.ToHex(b.GasLimit.Bytes())
// ext.MinGasPrice = common.ToHex(big.NewInt(b.MinGasPrice).Bytes())
ext.GasUsed = common.ToHex(b.GasUsed.Bytes())
@@ -111,7 +111,7 @@ func NewBlockRes(block *types.Block) *BlockRes {
res.Difficulty = block.Difficulty()
res.TotalDifficulty = block.Td
res.Size = big.NewInt(int64(block.Size()))
- // res.ExtraData =
+ res.ExtraData = []byte(block.Header().Extra)
res.GasLimit = block.GasLimit()
// res.MinGasPrice =
res.GasUsed = block.GasUsed()
@@ -243,8 +243,8 @@ func (l *LogRes) MarshalJSON() ([]byte, error) {
}
ext.Address = l.Address.Hex()
- ext.Data = common.Bytes2Hex(l.Data)
- ext.Number = common.Bytes2Hex(big.NewInt(int64(l.Number)).Bytes())
+ ext.Data = common.ToHex(l.Data)
+ ext.Number = common.ToHex(big.NewInt(int64(l.Number)).Bytes())
ext.Topics = make([]string, len(l.Topics))
for i, v := range l.Topics {
ext.Topics[i] = v.Hex()