mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46: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.IPCApiFlag,
|
||||
utils.IPCPathFlag,
|
||||
utils.IPCExperimental,
|
||||
utils.ExecFlag,
|
||||
utils.WhisperEnabledFlag,
|
||||
utils.DevModeFlag,
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ var AppHelpFlagGroups = []flagGroup{
|
|||
Flags: []cli.Flag{
|
||||
utils.WhisperEnabledFlag,
|
||||
utils.NatspecEnabledFlag,
|
||||
utils.IPCExperimental,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Reference in a new issue