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 committed by Péter Szilágyi
parent 5a687c8f4a
commit 3bff502d67
3 changed files with 39 additions and 31 deletions

View file

@ -313,6 +313,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

@ -305,6 +305,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)",
@ -778,7 +782,6 @@ func IpcSocketPath(ctx *cli.Context) (ipcpath string) {
return return
} }
// StartIPC starts a IPC JSON-RPC API server.
func StartIPC(stack *node.Node, ctx *cli.Context) error { func StartIPC(stack *node.Node, ctx *cli.Context) error {
var ethereum *eth.Ethereum var ethereum *eth.Ethereum
if err := stack.Service(&ethereum); err != nil { if err := stack.Service(&ethereum); err != nil {
@ -788,6 +791,8 @@ func StartIPC(stack *node.Node, ctx *cli.Context) error {
if err := stack.Service(&shh); err != nil { if err := stack.Service(&shh); err != nil {
return err return err
} }
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()))
@ -802,16 +807,14 @@ func StartIPC(stack *node.Node, ctx *cli.Context) error {
server.RegisterName("personal", accounts.NewPersonalService(ethereum.AccountManager())) server.RegisterName("personal", accounts.NewPersonalService(ethereum.AccountManager()))
server.RegisterName("shh", whisper.NewWhisperService(shh)) server.RegisterName("shh", whisper.NewWhisperService(shh))
ipcDir := filepath.Join(stack.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 {
@ -822,6 +825,9 @@ func StartIPC(stack *node.Node, ctx *cli.Context) error {
} }
}() }()
return nil
}
config := comms.IpcConfig{ config := comms.IpcConfig{
Endpoint: IpcSocketPath(ctx), Endpoint: IpcSocketPath(ctx),
} }