aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth/consolecmd.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-07-12 23:47:15 +0800
committerFelix Lange <fjl@twurst.com>2016-07-23 05:21:27 +0800
commit91b769042857f542b2792b23ec407e1c9bd4fe8d (patch)
treef6730b3e85a7ac5ca98f9a716505349958fcacd3 /cmd/geth/consolecmd.go
parentbb01bea4e276dad359815c682a2dee730737f4dc (diff)
downloadgo-tangerine-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar
go-tangerine-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.gz
go-tangerine-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.bz2
go-tangerine-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.lz
go-tangerine-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.xz
go-tangerine-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.zst
go-tangerine-91b769042857f542b2792b23ec407e1c9bd4fe8d.zip
rpc: add new client, use it everywhere
The new client implementation supports concurrent requests, subscriptions and replaces the various ad hoc RPC clients throughout go-ethereum.
Diffstat (limited to 'cmd/geth/consolecmd.go')
-rw-r--r--cmd/geth/consolecmd.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go
index 257050a62..8d53809ce 100644
--- a/cmd/geth/consolecmd.go
+++ b/cmd/geth/consolecmd.go
@@ -19,9 +19,12 @@ package main
import (
"os"
"os/signal"
+ "strings"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/console"
+ "github.com/ethereum/go-ethereum/node"
+ "github.com/ethereum/go-ethereum/rpc"
"gopkg.in/urfave/cli.v1"
)
@@ -99,7 +102,7 @@ func localConsole(ctx *cli.Context) error {
// console to it.
func remoteConsole(ctx *cli.Context) error {
// Attach to a remotely running geth instance and start the JavaScript console
- client, err := utils.NewRemoteRPCClient(ctx)
+ client, err := dialRPC(ctx.Args().First())
if err != nil {
utils.Fatalf("Unable to attach to remote geth: %v", err)
}
@@ -127,6 +130,20 @@ func remoteConsole(ctx *cli.Context) error {
return nil
}
+// dialRPC returns a RPC client which connects to the given endpoint.
+// The check for empty endpoint implements the defaulting logic
+// for "geth attach" and "geth monitor" with no argument.
+func dialRPC(endpoint string) (*rpc.Client, error) {
+ if endpoint == "" {
+ endpoint = node.DefaultIPCEndpoint()
+ } else if strings.HasPrefix(endpoint, "rpc:") || strings.HasPrefix(endpoint, "ipc:") {
+ // Backwards compatibility with geth < 1.5 which required
+ // these prefixes.
+ endpoint = endpoint[4:]
+ }
+ return rpc.Dial(endpoint)
+}
+
// ephemeralConsole starts a new geth node, attaches an ephemeral JavaScript
// console to it, and each of the files specified as arguments and tears the
// everything down.