added ipcexperimental flag to enable the new RPC implementation

This commit is contained in:
Bas van Kervel 2015-11-27 09:06:34 +01:00
parent e05a572329
commit e09cd88a7b
3 changed files with 38 additions and 30 deletions

View file

@ -328,6 +328,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.IPCDisabledFlag, utils.IPCDisabledFlag,
utils.IPCApiFlag, utils.IPCApiFlag,
utils.IPCPathFlag, utils.IPCPathFlag,
utils.IPCExperimental,
utils.ExecFlag, utils.ExecFlag,
utils.WhisperEnabledFlag, utils.WhisperEnabledFlag,
utils.DevModeFlag, utils.DevModeFlag,

View file

@ -158,6 +158,7 @@ var AppHelpFlagGroups = []flagGroup{
Flags: []cli.Flag{ Flags: []cli.Flag{
utils.WhisperEnabledFlag, utils.WhisperEnabledFlag,
utils.NatspecEnabledFlag, utils.NatspecEnabledFlag,
utils.IPCExperimental,
}, },
}, },
{ {

View file

@ -300,6 +300,10 @@ var (
Usage: "Filename for IPC socket/pipe", Usage: "Filename for IPC socket/pipe",
Value: DirectoryString{common.DefaultIpcPath()}, Value: DirectoryString{common.DefaultIpcPath()},
} }
IPCExperimental = cli.BoolFlag{
Name: "ipcexp",
Usage: "Enable the new RPC implementation",
}
ExecFlag = cli.StringFlag{ ExecFlag = cli.StringFlag{
Name: "exec", Name: "exec",
Usage: "Execute JavaScript statement (only in combination with console/attach)", Usage: "Execute JavaScript statement (only in combination with console/attach)",
@ -612,6 +616,7 @@ func IpcSocketPath(ctx *cli.Context) (ipcpath string) {
} }
func StartIPC(ethereum *eth.Ethereum, ctx *cli.Context) error { func StartIPC(ethereum *eth.Ethereum, ctx *cli.Context) error {
if ctx.GlobalIsSet(IPCExperimental.Name) {
server := rpc.NewServer() server := rpc.NewServer()
server.RegisterName("eth", accounts.NewAccountService(ethereum.AccountManager())) server.RegisterName("eth", accounts.NewAccountService(ethereum.AccountManager()))
@ -626,16 +631,14 @@ func StartIPC(ethereum *eth.Ethereum, ctx *cli.Context) error {
server.RegisterName("personal", accounts.NewPersonalService(ethereum.AccountManager())) server.RegisterName("personal", accounts.NewPersonalService(ethereum.AccountManager()))
server.RegisterName("shh", whisper.NewWhisperService(ethereum.Whisper())) server.RegisterName("shh", whisper.NewWhisperService(ethereum.Whisper()))
ipcDir := filepath.Join(ethereum.DataDir, "shared") ipcEndpoint := IpcSocketPath(ctx)
os.MkdirAll(ipcDir, 0700)
ipcEndpoint := filepath.Join(ipcDir, "ethereum.sock")
os.RemoveAll(ipcEndpoint) os.RemoveAll(ipcEndpoint)
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: ipcEndpoint, Net: "unix"}) l, err := net.ListenUnix("unix", &net.UnixAddr{Name: ipcEndpoint, Net: "unix"})
if err != nil { if err != nil {
panic(err) return err
} }
go func() { go func() {
glog.Infof("Unix socket for IPC service opened on %s\n", ipcEndpoint) glog.Infof("IPC endpoint(%s)\n", ipcEndpoint)
for { for {
conn, err := l.Accept() conn, err := l.Accept()
if err != nil { if err != nil {
@ -646,6 +649,9 @@ func StartIPC(ethereum *eth.Ethereum, ctx *cli.Context) error {
} }
}() }()
return nil
}
config := comms.IpcConfig{ config := comms.IpcConfig{
Endpoint: IpcSocketPath(ctx), Endpoint: IpcSocketPath(ctx),