Пример #1
0
// Start boots up the Ethereum protocol, starts interacting with the P2P network
// and opens up the IPC based JSOn RPC API for accessing the exposed APIs.
func (g *Geth) Start() error {
	// Assemble and start the protocol stack
	err := g.stack.Start()
	if err != nil {
		return err
	}
	// Attach an IPC endpoint to the stack (this should really have been done by the stack..)
	if runtime.GOOS == "windows" {
		g.ipcEndpoint = common.DefaultIpcPath()
	} else {
		g.ipcEndpoint = filepath.Join(g.stack.DataDir(), "geth.ipc")
	}
	if g.ipcSocket, err = rpc.CreateIPCListener(g.ipcEndpoint); err != nil {
		return err
	}
	// Iterate over all the APIs provided by the stack and expose them
	g.ipcServer = rpc.NewServer()
	for _, api := range g.stack.APIs() {
		log15.Debug("Exposing/extending API...", "namespace", api.Namespace, "runner", fmt.Sprintf("%T", api.Service))
		g.ipcServer.RegisterName(api.Namespace, api.Service)
	}
	log15.Info("Starting IPC listener...", "endpoint", g.ipcEndpoint)
	go g.handleIPC()

	return nil
}
Пример #2
0
func IPCSocketPath(ctx *cli.Context) (ipcpath string) {
	if runtime.GOOS == "windows" {
		ipcpath = common.DefaultIpcPath()
		if ctx.GlobalIsSet(IPCPathFlag.Name) {
			ipcpath = ctx.GlobalString(IPCPathFlag.Name)
		}
	} else {
		ipcpath = common.DefaultIpcPath()
		if ctx.GlobalIsSet(DataDirFlag.Name) {
			ipcpath = filepath.Join(ctx.GlobalString(DataDirFlag.Name), "geth.ipc")
		}
		if ctx.GlobalIsSet(IPCPathFlag.Name) {
			ipcpath = ctx.GlobalString(IPCPathFlag.Name)
		}
	}

	return
}
Пример #3
0
		Usage: "API's offered over the HTTP-RPC interface",
		Value: rpc.DefaultHttpRpcApis,
	}
	IPCDisabledFlag = cli.BoolFlag{
		Name:  "ipcdisable",
		Usage: "Disable the IPC-RPC server",
	}
	IPCApiFlag = cli.StringFlag{
		Name:  "ipcapi",
		Usage: "API's offered over the IPC-RPC interface",
		Value: rpc.DefaultIpcApis,
	}
	IPCPathFlag = DirectoryFlag{
		Name:  "ipcpath",
		Usage: "Filename for IPC socket/pipe",
		Value: DirectoryString{common.DefaultIpcPath()},
	}
	WSEnabledFlag = cli.BoolFlag{
		Name:  "ws",
		Usage: "Enable the WS-RPC server",
	}
	WSListenAddrFlag = cli.StringFlag{
		Name:  "wsaddr",
		Usage: "WS-RPC server listening interface",
		Value: "127.0.0.1",
	}
	WSPortFlag = cli.IntFlag{
		Name:  "wsport",
		Usage: "WS-RPC server listening port",
		Value: 8546,
	}