Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
60c2ccd9
Commit
60c2ccd9
authored
Jun 16, 2015
by
Bas van Kervel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made ipc handler generic and reusable
parent
9cf7913c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
28 deletions
+39
-28
comms.go
rpc/comms/comms.go
+38
-0
ipc_unix.go
rpc/comms/ipc_unix.go
+1
-28
No files found.
rpc/comms/comms.go
View file @
60c2ccd9
package
comms
import
(
"io"
"net"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc/api"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
)
type
EthereumClient
interface
{
Close
()
Send
(
interface
{})
error
Recv
()
(
interface
{},
error
)
}
func
handle
(
conn
net
.
Conn
,
api
api
.
EthereumApi
,
c
codec
.
Codec
)
{
codec
:=
c
.
New
(
conn
)
for
{
req
,
err
:=
codec
.
ReadRequest
()
if
err
==
io
.
EOF
{
codec
.
Close
()
return
}
else
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"IPC recv err - %v
\n
"
,
err
)
codec
.
Close
()
return
}
var
rpcResponse
interface
{}
res
,
err
:=
api
.
Execute
(
req
)
rpcResponse
=
shared
.
NewRpcResponse
(
req
.
Id
,
req
.
Jsonrpc
,
res
,
err
)
err
=
codec
.
WriteResponse
(
rpcResponse
)
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"comms send err - %v
\n
"
,
err
)
codec
.
Close
()
return
}
}
}
rpc/comms/ipc_unix.go
View file @
60c2ccd9
...
...
@@ -3,7 +3,6 @@
package
comms
import
(
"io"
"net"
"os"
...
...
@@ -11,7 +10,6 @@ import (
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc/api"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
)
func
newIpcClient
(
cfg
IpcConfig
,
codec
codec
.
Codec
)
(
*
ipcClient
,
error
)
{
...
...
@@ -40,32 +38,7 @@ func startIpc(cfg IpcConfig, codec codec.Codec, api api.EthereumApi) error {
continue
}
go
func
(
conn
net
.
Conn
)
{
codec
:=
codec
.
New
(
conn
)
for
{
req
,
err
:=
codec
.
ReadRequest
()
if
err
==
io
.
EOF
{
codec
.
Close
()
return
}
else
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"IPC recv err - %v
\n
"
,
err
)
codec
.
Close
()
return
}
var
rpcResponse
interface
{}
res
,
err
:=
api
.
Execute
(
req
)
rpcResponse
=
shared
.
NewRpcResponse
(
req
.
Id
,
req
.
Jsonrpc
,
res
,
err
)
err
=
codec
.
WriteResponse
(
rpcResponse
)
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"IPC send err - %v
\n
"
,
err
)
codec
.
Close
()
return
}
}
}(
conn
)
go
handle
(
conn
,
api
,
codec
)
}
os
.
Remove
(
cfg
.
Endpoint
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment