Beispiel #1
0
func attach(ctx *cli.Context) {
	var client comms.EthereumClient
	var err error
	if ctx.Args().Present() {
		client, err = comms.ClientFromEndpoint(ctx.Args().First(), codec.JSON)
	} else {
		cfg := comms.IpcConfig{
			Endpoint: utils.IpcSocketPath(ctx),
		}
		client, err = comms.NewIpcClient(cfg, codec.JSON)
	}

	if err != nil {
		utils.Fatalf("Unable to attach to geth node - %v", err)
	}

	repl := newLightweightJSRE(
		ctx.GlobalString(utils.JSpathFlag.Name),
		client,
		ctx.GlobalString(utils.DataDirFlag.Name),
		true,
	)

	if ctx.GlobalString(utils.ExecFlag.Name) != "" {
		repl.batch(ctx.GlobalString(utils.ExecFlag.Name))
	} else {
		repl.welcome()
		repl.interactive()
	}
}
Beispiel #2
0
func (app *EthereumApplication) StartIPC(ctx *cli.Context) error {
	eth := app.ethereum
	config := comms.IpcConfig{
		Endpoint: utils.IpcSocketPath(ctx),
	}

	initializer := func(conn net.Conn) (comms.Stopper, shared.EthereumApi, error) {
		fe := useragent.NewRemoteFrontend(conn, eth.AccountManager())
		xeth := xeth.NewFromApp(app, fe)
		ethApi := api.NewEthApi(xeth, eth, codec.JSON)
		personalApi := api.NewPersonalApi(xeth, eth, codec.JSON)
		web3Api := api.NewWeb3Api(xeth, codec.JSON)
		return xeth, api.Merge(ethApi, personalApi, web3Api), nil
	}

	return comms.StartIpc(config, codec.JSON, initializer)
}