aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils
diff options
context:
space:
mode:
authorbas-vk <bas-vk@users.noreply.github.com>2016-07-25 16:07:05 +0800
committerGitHub <noreply@github.com>2016-07-25 16:07:05 +0800
commit771655e3fee585ce4bc47dfaa279557c6c1c2421 (patch)
tree9071e157a54c40f06f0e5895643c82ca9a0b037a /cmd/utils
parent60cd5bf9397bd8331bce3bb1884524d43c31dbb5 (diff)
parent91b769042857f542b2792b23ec407e1c9bd4fe8d (diff)
downloaddexon-771655e3fee585ce4bc47dfaa279557c6c1c2421.tar
dexon-771655e3fee585ce4bc47dfaa279557c6c1c2421.tar.gz
dexon-771655e3fee585ce4bc47dfaa279557c6c1c2421.tar.bz2
dexon-771655e3fee585ce4bc47dfaa279557c6c1c2421.tar.lz
dexon-771655e3fee585ce4bc47dfaa279557c6c1c2421.tar.xz
dexon-771655e3fee585ce4bc47dfaa279557c6c1c2421.tar.zst
dexon-771655e3fee585ce4bc47dfaa279557c6c1c2421.zip
Merge pull request #2808 from fjl/rpc-client-3
rpc: add new client, use it everywhere
Diffstat (limited to 'cmd/utils')
-rw-r--r--cmd/utils/client.go55
1 files changed, 0 insertions, 55 deletions
diff --git a/cmd/utils/client.go b/cmd/utils/client.go
deleted file mode 100644
index cc9647580..000000000
--- a/cmd/utils/client.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
-//
-// go-ethereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// go-ethereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
-
-package utils
-
-import (
- "fmt"
- "strings"
-
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/rpc"
- "gopkg.in/urfave/cli.v1"
-)
-
-// NewRemoteRPCClient returns a RPC client which connects to a running geth instance.
-// Depending on the given context this can either be a IPC or a HTTP client.
-func NewRemoteRPCClient(ctx *cli.Context) (rpc.Client, error) {
- if ctx.Args().Present() {
- endpoint := ctx.Args().First()
- return NewRemoteRPCClientFromString(endpoint)
- }
- // use IPC by default
- return rpc.NewIPCClient(node.DefaultIPCEndpoint())
-}
-
-// NewRemoteRPCClientFromString returns a RPC client which connects to the given
-// endpoint. It must start with either `ipc:` or `rpc:` (HTTP).
-func NewRemoteRPCClientFromString(endpoint string) (rpc.Client, error) {
- if strings.HasPrefix(endpoint, "ipc:") {
- return rpc.NewIPCClient(endpoint[4:])
- }
- if strings.HasPrefix(endpoint, "rpc:") {
- return rpc.NewHTTPClient(endpoint[4:])
- }
- if strings.HasPrefix(endpoint, "http://") {
- return rpc.NewHTTPClient(endpoint)
- }
- if strings.HasPrefix(endpoint, "ws:") {
- return rpc.NewWSClient(endpoint)
- }
- return nil, fmt.Errorf("invalid endpoint")
-}