aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-08-25 18:23:25 +0800
committerFelix Lange <fjl@twurst.com>2015-08-25 18:23:25 +0800
commita219159e7e18ccaa52c9c493a19a11e6b7bab3dd (patch)
tree8d7d177b1d4ef721c7036076c533402308f5fe86
parentd51d0022cee91d6588186455afbe6e54fae2cbf7 (diff)
parentd910148a96cca05bc40ac5b5773effa9b92702f8 (diff)
downloadgo-tangerine-a219159e7e18ccaa52c9c493a19a11e6b7bab3dd.tar.gz
go-tangerine-a219159e7e18ccaa52c9c493a19a11e6b7bab3dd.tar.zst
go-tangerine-a219159e7e18ccaa52c9c493a19a11e6b7bab3dd.zip
Merge pull request #1710 from bas-vk/useragent
user agent messages were dumped in some cases
-rw-r--r--rpc/comms/ipc.go12
-rw-r--r--rpc/comms/ipc_unix.go23
-rw-r--r--rpc/comms/ipc_windows.go23
-rw-r--r--rpc/jeth.go10
4 files changed, 48 insertions, 20 deletions
diff --git a/rpc/comms/ipc.go b/rpc/comms/ipc.go
index d897bf313..3de659b65 100644
--- a/rpc/comms/ipc.go
+++ b/rpc/comms/ipc.go
@@ -42,16 +42,12 @@ func (self *ipcClient) Close() {
self.coder.Close()
}
-func (self *ipcClient) Send(req interface{}) error {
+func (self *ipcClient) Send(msg interface{}) error {
var err error
- if r, ok := req.(*shared.Request); ok {
- if err = self.coder.WriteResponse(r); err != nil {
- if err = self.reconnect(); err == nil {
- err = self.coder.WriteResponse(r)
- }
+ if err = self.coder.WriteResponse(msg); err != nil {
+ if err = self.reconnect(); err == nil {
+ err = self.coder.WriteResponse(msg)
}
-
- return err
}
return err
}
diff --git a/rpc/comms/ipc_unix.go b/rpc/comms/ipc_unix.go
index 24aefa5f3..9d90da071 100644
--- a/rpc/comms/ipc_unix.go
+++ b/rpc/comms/ipc_unix.go
@@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
+ "github.com/ethereum/go-ethereum/rpc/useragent"
)
func newIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
@@ -34,7 +35,18 @@ func newIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
return nil, err
}
- return &ipcClient{cfg.Endpoint, c, codec, codec.New(c)}, nil
+ coder := codec.New(c)
+ msg := shared.Request{
+ Id: 0,
+ Method: useragent.EnableUserAgentMethod,
+ Jsonrpc: shared.JsonRpcVersion,
+ Params: []byte("[]"),
+ }
+
+ coder.WriteResponse(msg)
+ coder.Recv()
+
+ return &ipcClient{cfg.Endpoint, c, codec, coder}, nil
}
func (self *ipcClient) reconnect() error {
@@ -42,6 +54,15 @@ func (self *ipcClient) reconnect() error {
c, err := net.DialUnix("unix", nil, &net.UnixAddr{self.endpoint, "unix"})
if err == nil {
self.coder = self.codec.New(c)
+
+ msg := shared.Request{
+ Id: 0,
+ Method: useragent.EnableUserAgentMethod,
+ Jsonrpc: shared.JsonRpcVersion,
+ Params: []byte("[]"),
+ }
+ self.coder.WriteResponse(msg)
+ self.coder.Recv()
}
return err
diff --git a/rpc/comms/ipc_windows.go b/rpc/comms/ipc_windows.go
index b2fe2b29d..47edd9e5b 100644
--- a/rpc/comms/ipc_windows.go
+++ b/rpc/comms/ipc_windows.go
@@ -32,6 +32,7 @@ import (
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
+ "github.com/ethereum/go-ethereum/rpc/useragent"
)
var (
@@ -656,13 +657,33 @@ func newIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
return nil, err
}
- return &ipcClient{cfg.Endpoint, c, codec, codec.New(c)}, nil
+ coder := codec.New(c)
+ msg := shared.Request{
+ Id: 0,
+ Method: useragent.EnableUserAgentMethod,
+ Jsonrpc: shared.JsonRpcVersion,
+ Params: []byte("[]"),
+ }
+
+ coder.WriteResponse(msg)
+ coder.Recv()
+
+ return &ipcClient{cfg.Endpoint, c, codec, coder}, nil
}
func (self *ipcClient) reconnect() error {
c, err := Dial(self.endpoint)
if err == nil {
self.coder = self.codec.New(c)
+
+ req := shared.Request{
+ Id: 0,
+ Method: useragent.EnableUserAgentMethod,
+ Jsonrpc: shared.JsonRpcVersion,
+ Params: []byte("[]"),
+ }
+ self.coder.WriteResponse(req)
+ self.coder.Recv()
}
return err
}
diff --git a/rpc/jeth.go b/rpc/jeth.go
index 158bfb64c..757f6b7eb 100644
--- a/rpc/jeth.go
+++ b/rpc/jeth.go
@@ -40,16 +40,6 @@ type Jeth struct {
}
func NewJeth(ethApi shared.EthereumApi, re *jsre.JSRE, client comms.EthereumClient, fe xeth.Frontend) *Jeth {
- // enable the jeth as the user agent
- req := shared.Request{
- Id: 0,
- Method: useragent.EnableUserAgentMethod,
- Jsonrpc: shared.JsonRpcVersion,
- Params: []byte("[]"),
- }
- client.Send(&req)
- client.Recv()
-
return &Jeth{ethApi, re, client, fe}
}