diff options
author | Bas van Kervel <basvankervel@gmail.com> | 2015-06-19 18:32:40 +0800 |
---|---|---|
committer | Bas van Kervel <bas@ethdev.com> | 2015-06-22 15:17:09 +0800 |
commit | ce5c94e4719586bbf81906cb90104babf79af0fe (patch) | |
tree | 66d873da0f69b7c3f925e63d749ebcecd4c47fde /rpc/comms/comms.go | |
parent | f20256377731097c9478ede750efffd46d83b494 (diff) | |
download | go-tangerine-ce5c94e4719586bbf81906cb90104babf79af0fe.tar.gz go-tangerine-ce5c94e4719586bbf81906cb90104babf79af0fe.tar.zst go-tangerine-ce5c94e4719586bbf81906cb90104babf79af0fe.zip |
added attach over http/rpc support
Diffstat (limited to 'rpc/comms/comms.go')
-rw-r--r-- | rpc/comms/comms.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rpc/comms/comms.go b/rpc/comms/comms.go index 7aa94b1ea..29ad11b3c 100644 --- a/rpc/comms/comms.go +++ b/rpc/comms/comms.go @@ -7,6 +7,8 @@ import ( "fmt" "strings" + "strconv" + "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/rpc/api" @@ -82,7 +84,28 @@ func ClientFromEndpoint(endpoint string, c codec.Codec) (EthereumClient, error) } if strings.HasPrefix(endpoint, "rpc:") { + parts := strings.Split(endpoint, ":") + addr := "http://localhost" + port := uint(8545) + if len(parts) >= 3 { + addr = parts[1] + ":" + parts[2] + } + + if len(parts) >= 4 { + p, err := strconv.Atoi(parts[3]) + + if err != nil { + return nil, err + } + port = uint(p) + } + + cfg := HttpConfig{ + ListenAddress: addr, + ListenPort: port, + } + return NewHttpClient(cfg, codec.JSON), nil } return nil, fmt.Errorf("Invalid endpoint") |