mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
added ipcexperimental flag to enable the new RPC implementation
This commit is contained in:
parent
e05a572329
commit
e09cd88a7b
3 changed files with 38 additions and 30 deletions
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,7 @@ var AppHelpFlagGroups = []flagGroup{
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.WhisperEnabledFlag,
|
utils.WhisperEnabledFlag,
|
||||||
utils.NatspecEnabledFlag,
|
utils.NatspecEnabledFlag,
|
||||||
|
utils.IPCExperimental,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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,39 +616,41 @@ 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 {
|
||||||
server := rpc.NewServer()
|
if ctx.GlobalIsSet(IPCExperimental.Name) {
|
||||||
|
server := rpc.NewServer()
|
||||||
|
|
||||||
server.RegisterName("eth", accounts.NewAccountService(ethereum.AccountManager()))
|
server.RegisterName("eth", accounts.NewAccountService(ethereum.AccountManager()))
|
||||||
server.RegisterName("eth", core.NewBlockChainService(ethereum.BlockChain(), 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", core.NewTransactionPoolService(ethereum.TxPool(), ethereum.ChainDb(), ethereum.BlockChain(), ethereum.AccountManager()))
|
||||||
server.RegisterName("eth", miner.NewMinerService(ethereum.Miner()))
|
server.RegisterName("eth", miner.NewMinerService(ethereum.Miner()))
|
||||||
server.RegisterName("eth", eth.NewEthService(ethereum))
|
server.RegisterName("eth", eth.NewEthService(ethereum))
|
||||||
server.RegisterName("eth", downloader.NewDownloaderService(ethereum.Downloader()))
|
server.RegisterName("eth", downloader.NewDownloaderService(ethereum.Downloader()))
|
||||||
server.RegisterName("eth", filters.NewFilterService(ethereum.ChainDb(), ethereum.EventMux()))
|
server.RegisterName("eth", filters.NewFilterService(ethereum.ChainDb(), ethereum.EventMux()))
|
||||||
server.RegisterName("net", p2p.NewNetService(ethereum.Network(), ethereum.NetVersion()))
|
server.RegisterName("net", p2p.NewNetService(ethereum.Network(), ethereum.NetVersion()))
|
||||||
server.RegisterName("web3", eth.NewWeb3Service(ethereum))
|
server.RegisterName("web3", eth.NewWeb3Service(ethereum))
|
||||||
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)
|
os.RemoveAll(ipcEndpoint)
|
||||||
ipcEndpoint := filepath.Join(ipcDir, "ethereum.sock")
|
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: ipcEndpoint, Net: "unix"})
|
||||||
os.RemoveAll(ipcEndpoint)
|
if err != nil {
|
||||||
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: ipcEndpoint, Net: "unix"})
|
return err
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}()
|
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{
|
config := comms.IpcConfig{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue