cmd, node, rpc: move websockets into node, break singleton

This commit is contained in:
Péter Szilágyi
2016-02-05 15:08:48 +02:00
parent a13bc9d7a1
commit 7486904b92
11 changed files with 194 additions and 292 deletions

View File

@ -312,7 +312,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.WSListenAddrFlag,
utils.WSPortFlag,
utils.WSApiFlag,
utils.WSAllowedDomainsFlag,
utils.WSCORSDomainFlag,
utils.IPCDisabledFlag,
utils.IPCApiFlag,
utils.IPCPathFlag,
@ -399,7 +399,7 @@ func attach(ctx *cli.Context) {
// attach to a running geth instance
client, err := utils.NewRemoteRPCClient(ctx)
if err != nil {
utils.Fatalf("Unable to attach to geth - %v", err)
utils.Fatalf("Unable to attach to geth: %v", err)
}
repl := newLightweightJSRE(
@ -425,8 +425,10 @@ func console(ctx *cli.Context) {
startNode(ctx, node)
// Attach to the newly started node, and either execute script or become interactive
client := utils.NewInProcRPCClient(node)
client, err := utils.NewRemoteRPCClientFromString("ipc:" + node.IpcEndpoint())
if err != nil {
utils.Fatalf("Failed to attach to the inproc geth: %v", err)
}
repl := newJSRE(node,
ctx.GlobalString(utils.JSpathFlag.Name),
ctx.GlobalString(utils.RPCCORSDomainFlag.Name),
@ -449,8 +451,10 @@ func execScripts(ctx *cli.Context) {
startNode(ctx, node)
// Attach to the newly started node and execute the given scripts
client := utils.NewInProcRPCClient(node)
client, err := utils.NewRemoteRPCClientFromString("ipc:" + node.IpcEndpoint())
if err != nil {
utils.Fatalf("Failed to attach to the inproc geth: %v", err)
}
repl := newJSRE(node,
ctx.GlobalString(utils.JSpathFlag.Name),
ctx.GlobalString(utils.RPCCORSDomainFlag.Name),
@ -503,11 +507,6 @@ func startNode(ctx *cli.Context, stack *node.Node) {
}
}
// Start auxiliary services if enabled
if ctx.GlobalBool(utils.WSEnabledFlag.Name) {
if err := utils.StartWS(stack, ctx); err != nil {
utils.Fatalf("Failed to start WS: %v", err)
}
}
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
if err := ethereum.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name), ctx.GlobalString(utils.MiningGPUFlag.Name)); err != nil {
utils.Fatalf("Failed to start mining: %v", err)