|
|
@ -26,6 +26,7 @@ import ( |
|
|
|
"github.com/ethereum/go-ethereum/logger/glog" |
|
|
|
"github.com/ethereum/go-ethereum/logger/glog" |
|
|
|
"github.com/ethereum/go-ethereum/rpc/codec" |
|
|
|
"github.com/ethereum/go-ethereum/rpc/codec" |
|
|
|
"github.com/ethereum/go-ethereum/rpc/shared" |
|
|
|
"github.com/ethereum/go-ethereum/rpc/shared" |
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/rpc/useragent" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func newIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) { |
|
|
|
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 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 { |
|
|
|
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"}) |
|
|
|
c, err := net.DialUnix("unix", nil, &net.UnixAddr{self.endpoint, "unix"}) |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
self.coder = self.codec.New(c) |
|
|
|
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 |
|
|
|
return err |
|
|
|