diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 82bc21ab05..45812e9e19 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -328,6 +328,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.IPCDisabledFlag, utils.IPCApiFlag, utils.IPCPathFlag, + utils.IPCExperimental, utils.ExecFlag, utils.WhisperEnabledFlag, utils.DevModeFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 5c09e29ce4..7a6ff704c4 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -158,6 +158,7 @@ var AppHelpFlagGroups = []flagGroup{ Flags: []cli.Flag{ utils.WhisperEnabledFlag, utils.NatspecEnabledFlag, + utils.IPCExperimental, }, }, { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 39e594b006..0131fb5e13 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -300,6 +300,10 @@ var ( Usage: "Filename for IPC socket/pipe", Value: DirectoryString{common.DefaultIpcPath()}, } + IPCExperimental = cli.BoolFlag{ + Name: "ipcexp", + Usage: "Enable the new RPC implementation", + } ExecFlag = cli.StringFlag{ Name: "exec", Usage: "Execute JavaScript statement (only in combination with console/attach)", @@ -612,39 +616,41 @@ func IpcSocketPath(ctx *cli.Context) (ipcpath string) { } func StartIPC(ethereum *eth.Ethereum, ctx *cli.Context) error { - server := rpc.NewServer() + if ctx.GlobalIsSet(IPCExperimental.Name) { + server := rpc.NewServer() - server.RegisterName("eth", accounts.NewAccountService(ethereum.AccountManager())) - server.RegisterName("eth", core.NewBlockChainService(ethereum.BlockChain(), ethereum.AccountManager())) - server.RegisterName("eth", core.NewTransactionPoolService(ethereum.TxPool(), ethereum.ChainDb(), ethereum.BlockChain(), ethereum.AccountManager())) - server.RegisterName("eth", miner.NewMinerService(ethereum.Miner())) - server.RegisterName("eth", eth.NewEthService(ethereum)) - server.RegisterName("eth", downloader.NewDownloaderService(ethereum.Downloader())) - server.RegisterName("eth", filters.NewFilterService(ethereum.ChainDb(), ethereum.EventMux())) - server.RegisterName("net", p2p.NewNetService(ethereum.Network(), ethereum.NetVersion())) - server.RegisterName("web3", eth.NewWeb3Service(ethereum)) - server.RegisterName("personal", accounts.NewPersonalService(ethereum.AccountManager())) - server.RegisterName("shh", whisper.NewWhisperService(ethereum.Whisper())) + server.RegisterName("eth", accounts.NewAccountService(ethereum.AccountManager())) + server.RegisterName("eth", core.NewBlockChainService(ethereum.BlockChain(), ethereum.AccountManager())) + server.RegisterName("eth", core.NewTransactionPoolService(ethereum.TxPool(), ethereum.ChainDb(), ethereum.BlockChain(), ethereum.AccountManager())) + server.RegisterName("eth", miner.NewMinerService(ethereum.Miner())) + server.RegisterName("eth", eth.NewEthService(ethereum)) + server.RegisterName("eth", downloader.NewDownloaderService(ethereum.Downloader())) + server.RegisterName("eth", filters.NewFilterService(ethereum.ChainDb(), ethereum.EventMux())) + server.RegisterName("net", p2p.NewNetService(ethereum.Network(), ethereum.NetVersion())) + server.RegisterName("web3", eth.NewWeb3Service(ethereum)) + server.RegisterName("personal", accounts.NewPersonalService(ethereum.AccountManager())) + server.RegisterName("shh", whisper.NewWhisperService(ethereum.Whisper())) - ipcDir := filepath.Join(ethereum.DataDir, "shared") - os.MkdirAll(ipcDir, 0700) - ipcEndpoint := filepath.Join(ipcDir, "ethereum.sock") - os.RemoveAll(ipcEndpoint) - l, err := net.ListenUnix("unix", &net.UnixAddr{Name: ipcEndpoint, Net: "unix"}) - if err != nil { - panic(err) - } - go func() { - glog.Infof("Unix socket for IPC service opened on %s\n", ipcEndpoint) - for { - conn, err := l.Accept() - if err != nil { - panic(err) - } - codec := rpc.NewJSONCodec(conn) - go server.ServeCodec(codec) + 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) + for { + conn, err := l.Accept() + if err != nil { + panic(err) + } + codec := rpc.NewJSONCodec(conn) + go server.ServeCodec(codec) + } + }() + + return nil + } config := comms.IpcConfig{