mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
added Windows support for experimental IPC interface
This commit is contained in:
parent
3bff502d67
commit
b29774c4f2
2 changed files with 16 additions and 14 deletions
|
|
@ -791,8 +791,14 @@ func StartIPC(stack *node.Node, ctx *cli.Context) error {
|
|||
if err := stack.Service(&shh); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
config := comms.IpcConfig{
|
||||
Endpoint: IpcSocketPath(ctx),
|
||||
}
|
||||
if ctx.GlobalIsSet(IPCExperimental.Name) {
|
||||
listener, err := comms.CreateListener(config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
server := rpc.NewServer()
|
||||
|
||||
server.RegisterName("eth", accounts.NewAccountService(ethereum.AccountManager()))
|
||||
|
|
@ -807,18 +813,13 @@ func StartIPC(stack *node.Node, ctx *cli.Context) error {
|
|||
server.RegisterName("personal", accounts.NewPersonalService(ethereum.AccountManager()))
|
||||
server.RegisterName("shh", whisper.NewWhisperService(shh))
|
||||
|
||||
ipcEndpoint := IpcSocketPath(ctx)
|
||||
os.RemoveAll(ipcEndpoint)
|
||||
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: ipcEndpoint, Net: "unix"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
glog.Infof("IPC endpoint(%s)\n", ipcEndpoint)
|
||||
glog.Infof("IPC Service endpoint(%s)\n", config.Endpoint)
|
||||
for {
|
||||
conn, err := l.Accept()
|
||||
conn, err := listener.Accept()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
glog.Errorf("%v\n", err)
|
||||
continue
|
||||
}
|
||||
codec := rpc.NewJSONCodec(conn)
|
||||
go server.ServeCodec(codec)
|
||||
|
|
@ -828,10 +829,6 @@ func StartIPC(stack *node.Node, ctx *cli.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
config := comms.IpcConfig{
|
||||
Endpoint: IpcSocketPath(ctx),
|
||||
}
|
||||
|
||||
initializer := func(conn net.Conn) (comms.Stopper, shared.EthereumApi, error) {
|
||||
fe := useragent.NewRemoteFrontend(conn, ethereum.AccountManager())
|
||||
xeth := xeth.New(stack, fe)
|
||||
|
|
|
|||
|
|
@ -124,6 +124,11 @@ func StartIpc(cfg IpcConfig, codec codec.Codec, initializer InitFunc) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// CreateListener creates an listener, on Unix platforms this is a unix socket, on Windows this is a named pipe
|
||||
func CreateListener(cfg IpcConfig) (net.Listener, error) {
|
||||
return ipcListen(cfg)
|
||||
}
|
||||
|
||||
func ipcLoop(cfg IpcConfig, codec codec.Codec, initializer InitFunc, l net.Listener) {
|
||||
glog.V(logger.Info).Infof("IPC service started (%s)\n", cfg.Endpoint)
|
||||
defer os.Remove(cfg.Endpoint)
|
||||
|
|
|
|||
Loading…
Reference in a new issue