Browse Source

Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop

obscuren 10 years ago
parent
commit
e1c6c01b4d
7 changed files with 18 additions and 26 deletions
  1. 1 1
      .travis.yml
  2. 2 2
      Dockerfile
  3. 2 2
      README.md
  4. 1 2
      rpc/api.go
  5. 7 14
      rpc/args.go
  6. 1 1
      rpc/http.go
  7. 4 4
      rpc/responses.go

+ 1 - 1
.travis.yml

@@ -9,7 +9,7 @@ install:
   # - go get code.google.com/p/go.tools/cmd/goimports
   # - go get code.google.com/p/go.tools/cmd/goimports
   # - go get github.com/golang/lint/golint
   # - go get github.com/golang/lint/golint
   # - go get golang.org/x/tools/cmd/vet 
   # - go get golang.org/x/tools/cmd/vet 
-  - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
+  - go get golang.org/x/tools/cmd/cover
   - go get github.com/mattn/goveralls
   - go get github.com/mattn/goveralls
 before_script:
 before_script:
   # - gofmt -l -w .
   # - gofmt -l -w .

+ 2 - 2
Dockerfile

@@ -30,10 +30,10 @@ RUN mkdir -p $GOPATH/src/github.com/ethereum/
 RUN git clone https://github.com/ethereum/go-ethereum $GOPATH/src/github.com/ethereum/go-ethereum
 RUN git clone https://github.com/ethereum/go-ethereum $GOPATH/src/github.com/ethereum/go-ethereum
 WORKDIR $GOPATH/src/github.com/ethereum/go-ethereum
 WORKDIR $GOPATH/src/github.com/ethereum/go-ethereum
 RUN git checkout develop
 RUN git checkout develop
-RUN GOPATH=$GOPATH:$GOPATH/src/github.com/ethereum/go-ethereum/Godeps/_workspace go install -v ./cmd/ethereum
+RUN GOPATH=$GOPATH:$GOPATH/src/github.com/ethereum/go-ethereum/Godeps/_workspace go install -v ./cmd/geth
 
 
 ## Run & expose JSON RPC
 ## Run & expose JSON RPC
-ENTRYPOINT ["ethereum", "-rpc=true", "-rpcport=8545"]
+ENTRYPOINT ["geth", "-rpc=true", "-rpcport=8545"]
 EXPOSE 8545
 EXPOSE 8545
 
 
 
 

+ 2 - 2
README.md

@@ -4,8 +4,8 @@ Ethereum Go Client © 2014 Jeffrey Wilcke.
 
 
           | Linux   | OSX | Windows | Tests
           | Linux   | OSX | Windows | Tests
 ----------|---------|-----|---------|------
 ----------|---------|-----|---------|------
-develop   | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](https://build.ethdev.com/builders/Linux%20Go%20develop%20branch/builds/-1) | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](https://build.ethdev.com/builders/OSX%20Go%20develop%20branch/builds/-1) | N/A | [![Buildr+Status](https://travis-ci.org/ethereum/go-ethereum.svg?branch=develop)](https://travis-ci.org/ethereum/go-ethereum)
-master    | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20master%20branch)](https://build.ethdev.com/builders/Linux%20Go%20master%20branch/builds/-1) | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=OSX%20Go%20master%20branch)](https://build.ethdev.com/builders/OSX%20Go%20master%20branch/builds/-1) | N/A | [![Buildr+Status](https://travis-ci.org/ethereum/go-ethereum.svg?branch=master)](https://travis-ci.org/ethereum/go-ethereum)
+develop   | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](https://build.ethdev.com/builders/Linux%20Go%20develop%20branch/builds/-1) | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](https://build.ethdev.com/builders/OSX%20Go%20develop%20branch/builds/-1) | N/A | [![Buildr+Status](https://travis-ci.org/ethereum/go-ethereum.svg?branch=develop)](https://travis-ci.org/ethereum/go-ethereum) [![Coverage Status](https://coveralls.io/repos/ethereum/go-ethereum/badge.svg?branch=develop)](https://coveralls.io/r/ethereum/go-ethereum?branch=develop)
+master    | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20master%20branch)](https://build.ethdev.com/builders/Linux%20Go%20master%20branch/builds/-1) | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=OSX%20Go%20master%20branch)](https://build.ethdev.com/builders/OSX%20Go%20master%20branch/builds/-1) | N/A | [![Buildr+Status](https://travis-ci.org/ethereum/go-ethereum.svg?branch=master)](https://travis-ci.org/ethereum/go-ethereum) [![Coverage Status](https://coveralls.io/repos/ethereum/go-ethereum/badge.svg?branch=master)](https://coveralls.io/r/ethereum/go-ethereum?branch=master)
 
 
 [![Bugs](https://badge.waffle.io/ethereum/go-ethereum.png?label=bug&title=Bugs)](https://waffle.io/ethereum/go-ethereum)
 [![Bugs](https://badge.waffle.io/ethereum/go-ethereum.png?label=bug&title=Bugs)](https://waffle.io/ethereum/go-ethereum)
 [![Stories in Ready](https://badge.waffle.io/ethereum/go-ethereum.png?label=ready&title=Ready)](https://waffle.io/ethereum/go-ethereum)
 [![Stories in Ready](https://badge.waffle.io/ethereum/go-ethereum.png?label=ready&title=Ready)](https://waffle.io/ethereum/go-ethereum)

+ 1 - 2
rpc/api.go

@@ -13,7 +13,6 @@ import (
 type EthereumApi struct {
 type EthereumApi struct {
 	eth    *xeth.XEth
 	eth    *xeth.XEth
 	xethMu sync.RWMutex
 	xethMu sync.RWMutex
-	db     common.Database
 }
 }
 
 
 func NewEthereumApi(xeth *xeth.XEth) *EthereumApi {
 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)
 		state := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address)
 		value := state.StorageString(args.Key)
 		value := state.StorageString(args.Key)
 
 
-		*reply = common.Bytes2Hex(value.Bytes())
+		*reply = common.ToHex(value.Bytes())
 	case "eth_getTransactionCount":
 	case "eth_getTransactionCount":
 		args := new(GetTxCountArgs)
 		args := new(GetTxCountArgs)
 		if err := json.Unmarshal(req.Params, &args); err != nil {
 		if err := json.Unmarshal(req.Params, &args); err != nil {

+ 7 - 14
rpc/args.go

@@ -1,9 +1,7 @@
 package rpc
 package rpc
 
 
 import (
 import (
-	"bytes"
 	"encoding/json"
 	"encoding/json"
-	// "errors"
 	"fmt"
 	"fmt"
 	"math/big"
 	"math/big"
 
 
@@ -105,8 +103,8 @@ type GetBlockByHashArgs struct {
 
 
 func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
 func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
 	var obj []interface{}
 	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())
 		return NewDecodeParamError(err.Error())
 	}
 	}
 
 
@@ -134,8 +132,7 @@ type GetBlockByNumberArgs struct {
 
 
 func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
 func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
 	var obj []interface{}
 	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())
 		return NewDecodeParamError(err.Error())
 	}
 	}
 
 
@@ -405,8 +402,7 @@ type BlockNumIndexArgs struct {
 
 
 func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
 func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
 	var obj []interface{}
 	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())
 		return NewDecodeParamError(err.Error())
 	}
 	}
 
 
@@ -436,8 +432,7 @@ type HashIndexArgs struct {
 
 
 func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) {
 func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) {
 	var obj []interface{}
 	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())
 		return NewDecodeParamError(err.Error())
 	}
 	}
 
 
@@ -468,8 +463,7 @@ type Sha3Args struct {
 
 
 func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) {
 func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) {
 	var obj []interface{}
 	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())
 		return NewDecodeParamError(err.Error())
 	}
 	}
 
 
@@ -798,8 +792,7 @@ type FilterStringArgs struct {
 
 
 func (args *FilterStringArgs) UnmarshalJSON(b []byte) (err error) {
 func (args *FilterStringArgs) UnmarshalJSON(b []byte) (err error) {
 	var obj []interface{}
 	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())
 		return NewDecodeParamError(err.Error())
 	}
 	}
 
 

+ 1 - 1
rpc/http.go

@@ -76,7 +76,7 @@ func RpcResponse(api *EthereumApi, request *RpcRequest) *interface{} {
 	case *NotImplementedError:
 	case *NotImplementedError:
 		jsonerr := &RpcErrorObject{-32601, reserr.Error()}
 		jsonerr := &RpcErrorObject{-32601, reserr.Error()}
 		response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr}
 		response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr}
-	case *DecodeParamError, *InsufficientParamsError, *ValidationError:
+	case *DecodeParamError, *InsufficientParamsError, *ValidationError, *InvalidTypeError:
 		jsonerr := &RpcErrorObject{-32602, reserr.Error()}
 		jsonerr := &RpcErrorObject{-32602, reserr.Error()}
 		response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr}
 		response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr}
 	default:
 	default:

+ 4 - 4
rpc/responses.go

@@ -70,7 +70,7 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
 	ext.Difficulty = common.ToHex(b.Difficulty.Bytes())
 	ext.Difficulty = common.ToHex(b.Difficulty.Bytes())
 	ext.TotalDifficulty = common.ToHex(b.TotalDifficulty.Bytes())
 	ext.TotalDifficulty = common.ToHex(b.TotalDifficulty.Bytes())
 	ext.Size = common.ToHex(b.Size.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.GasLimit = common.ToHex(b.GasLimit.Bytes())
 	// ext.MinGasPrice = common.ToHex(big.NewInt(b.MinGasPrice).Bytes())
 	// ext.MinGasPrice = common.ToHex(big.NewInt(b.MinGasPrice).Bytes())
 	ext.GasUsed = common.ToHex(b.GasUsed.Bytes())
 	ext.GasUsed = common.ToHex(b.GasUsed.Bytes())
@@ -111,7 +111,7 @@ func NewBlockRes(block *types.Block) *BlockRes {
 	res.Difficulty = block.Difficulty()
 	res.Difficulty = block.Difficulty()
 	res.TotalDifficulty = block.Td
 	res.TotalDifficulty = block.Td
 	res.Size = big.NewInt(int64(block.Size()))
 	res.Size = big.NewInt(int64(block.Size()))
-	// res.ExtraData =
+	res.ExtraData = []byte(block.Header().Extra)
 	res.GasLimit = block.GasLimit()
 	res.GasLimit = block.GasLimit()
 	// res.MinGasPrice =
 	// res.MinGasPrice =
 	res.GasUsed = block.GasUsed()
 	res.GasUsed = block.GasUsed()
@@ -243,8 +243,8 @@ func (l *LogRes) MarshalJSON() ([]byte, error) {
 	}
 	}
 
 
 	ext.Address = l.Address.Hex()
 	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))
 	ext.Topics = make([]string, len(l.Topics))
 	for i, v := range l.Topics {
 	for i, v := range l.Topics {
 		ext.Topics[i] = v.Hex()
 		ext.Topics[i] = v.Hex()