aboutsummaryrefslogtreecommitdiffstats
path: root/ethrpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-27 01:55:14 +0800
committerobscuren <geffobscura@gmail.com>2014-06-27 01:55:14 +0800
commit9d5a3f013121c319f9cf679d9afc4e40661a0284 (patch)
treef57ecbea40ca0354bb050d70a10851669412a581 /ethrpc
parent3f1f8438ed8bf7b63ea5172090a5c7025cb093f0 (diff)
parenta98e6a262a21ff08c28495bab5180a1c15826d40 (diff)
downloadgo-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.gz
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.bz2
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.lz
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.xz
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.zst
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.zip
Merge branch 'release/0.5.15'
Diffstat (limited to 'ethrpc')
-rw-r--r--ethrpc/packages.go14
-rw-r--r--ethrpc/server.go12
2 files changed, 18 insertions, 8 deletions
diff --git a/ethrpc/packages.go b/ethrpc/packages.go
index 1c4fb99f6..710275780 100644
--- a/ethrpc/packages.go
+++ b/ethrpc/packages.go
@@ -6,6 +6,7 @@ import (
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"math/big"
+ "strings"
)
type EthereumApi struct {
@@ -174,9 +175,16 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *string) error {
return err
}
state := p.ethp.GetStateObject(args.Address)
- // Convert the incoming string (which is a bigint) into hex
- i, _ := new(big.Int).SetString(args.Key, 10)
- hx := ethutil.Hex(i.Bytes())
+
+ var hx string
+ if strings.Index(args.Key, "0x") == 0 {
+ hx = string([]byte(args.Key)[2:])
+ } else {
+ // Convert the incoming string (which is a bigint) into hex
+ i, _ := new(big.Int).SetString(args.Key, 10)
+ hx = ethutil.Hex(i.Bytes())
+ }
+ logger.Debugf("GetStorageAt(%s, %s)\n", args.Address, hx)
value := state.GetStorage(hx)
*reply = NewSuccessRes(GetStorageAtRes{Address: args.Address, Key: args.Key, Value: value})
return nil
diff --git a/ethrpc/server.go b/ethrpc/server.go
index 3960e641c..d9d6f695b 100644
--- a/ethrpc/server.go
+++ b/ethrpc/server.go
@@ -2,13 +2,15 @@ package ethrpc
import (
"fmt"
+ "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethpub"
- "github.com/ethereum/eth-go/ethutil"
"net"
"net/rpc"
"net/rpc/jsonrpc"
)
+var logger = ethlog.NewLogger("JSON")
+
type JsonRpcServer struct {
quit chan bool
listener net.Listener
@@ -25,7 +27,7 @@ out:
}
}
- ethutil.Config.Log.Infoln("[JSON] Shutdown JSON-RPC server")
+ logger.Infoln("Shutdown JSON-RPC server")
}
func (s *JsonRpcServer) Stop() {
@@ -33,7 +35,7 @@ func (s *JsonRpcServer) Stop() {
}
func (s *JsonRpcServer) Start() {
- ethutil.Config.Log.Infoln("[JSON] Starting JSON-RPC server")
+ logger.Infoln("Starting JSON-RPC server")
go s.exitHandler()
rpc.Register(&EthereumApi{ethp: s.ethp})
rpc.HandleHTTP()
@@ -41,10 +43,10 @@ func (s *JsonRpcServer) Start() {
for {
conn, err := s.listener.Accept()
if err != nil {
- ethutil.Config.Log.Infoln("[JSON] Error starting JSON-RPC:", err)
+ logger.Infoln("Error starting JSON-RPC:", err)
break
}
- ethutil.Config.Log.Debugln("[JSON] Incoming request.")
+ logger.Debugln("Incoming request.")
go jsonrpc.ServeConn(conn)
}
}