aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/comms/ipc.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-08-14 07:25:33 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-08-14 07:25:33 +0800
commit28b14d3e6d43cb27019e21d0a93a80e7bee1de8c (patch)
tree9995026e87221a80cb5171364ffa734459c16b16 /rpc/comms/ipc.go
parent73c4e6005c3e47342a4631955ca6fd2782925886 (diff)
parentf9cbd16f27e393d4937354ee31435e0a2f689484 (diff)
downloadgo-tangerine-28b14d3e6d43cb27019e21d0a93a80e7bee1de8c.tar.gz
go-tangerine-28b14d3e6d43cb27019e21d0a93a80e7bee1de8c.tar.zst
go-tangerine-28b14d3e6d43cb27019e21d0a93a80e7bee1de8c.zip
Merge pull request #1635 from bas-vk/useragent
support for user agents
Diffstat (limited to 'rpc/comms/ipc.go')
-rw-r--r--rpc/comms/ipc.go35
1 files changed, 9 insertions, 26 deletions
diff --git a/rpc/comms/ipc.go b/rpc/comms/ipc.go
index 0250aa01e..e982ada13 100644
--- a/rpc/comms/ipc.go
+++ b/rpc/comms/ipc.go
@@ -44,35 +44,18 @@ func (self *ipcClient) Close() {
func (self *ipcClient) Send(req interface{}) error {
var err error
- if r, ok := req.(*shared.Request); ok {
- if err = self.coder.WriteResponse(r); err != nil {
- if _, ok := err.(*net.OpError); ok { // connection lost, retry once
- if err = self.reconnect(); err == nil {
- err = self.coder.WriteResponse(r)
- }
+ if err = self.coder.WriteResponse(req); err != nil {
+ if _, ok := err.(*net.OpError); ok { // connection lost, retry once
+ if err = self.reconnect(); err == nil {
+ err = self.coder.WriteResponse(req)
}
}
- return err
}
-
- return fmt.Errorf("Invalid request (%T)", req)
+ return err
}
func (self *ipcClient) Recv() (interface{}, error) {
- res, err := self.coder.ReadResponse()
- if err != nil {
- return nil, err
- }
-
- if r, ok := res.(shared.SuccessResponse); ok {
- return r.Result, nil
- }
-
- if r, ok := res.(shared.ErrorResponse); ok {
- return r.Error, nil
- }
-
- return res, err
+ return self.coder.ReadResponse()
}
func (self *ipcClient) SupportedModules() (map[string]string, error) {
@@ -91,7 +74,7 @@ func (self *ipcClient) SupportedModules() (map[string]string, error) {
return nil, err
}
- if sucRes, ok := res.(shared.SuccessResponse); ok {
+ if sucRes, ok := res.(*shared.SuccessResponse); ok {
data, _ := json.Marshal(sucRes.Result)
modules := make(map[string]string)
err = json.Unmarshal(data, &modules)
@@ -109,8 +92,8 @@ func NewIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
}
// Start IPC server
-func StartIpc(cfg IpcConfig, codec codec.Codec, offeredApi shared.EthereumApi) error {
- return startIpc(cfg, codec, offeredApi)
+func StartIpc(cfg IpcConfig, codec codec.Codec, initializer func(conn net.Conn) (shared.EthereumApi, error)) error {
+ return startIpc(cfg, codec, initializer)
}
func newIpcConnId() int {