diff options
author | Bas van Kervel <bas@ethdev.com> | 2015-06-19 00:23:13 +0800 |
---|---|---|
committer | Bas van Kervel <bas@ethdev.com> | 2015-06-22 15:17:09 +0800 |
commit | f20256377731097c9478ede750efffd46d83b494 (patch) | |
tree | 25ea2b0de5382ed25dde5ff2021214625f3e9865 /rpc/comms/comms.go | |
parent | 36a6b16a3bec15131318ebed1c8c2f9204a5a328 (diff) | |
download | go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.gz go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.bz2 go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.lz go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.xz go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.zst go-tangerine-f20256377731097c9478ede750efffd46d83b494.zip |
added attach over ipc command
Diffstat (limited to 'rpc/comms/comms.go')
-rw-r--r-- | rpc/comms/comms.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/rpc/comms/comms.go b/rpc/comms/comms.go index 050e7b4e2..7aa94b1ea 100644 --- a/rpc/comms/comms.go +++ b/rpc/comms/comms.go @@ -4,12 +4,14 @@ import ( "io" "net" + "fmt" + "strings" + "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/rpc/api" "github.com/ethereum/go-ethereum/rpc/codec" "github.com/ethereum/go-ethereum/rpc/shared" - "strings" ) const ( @@ -26,7 +28,7 @@ var ( // List with API's which are offered over thr HTTP/RPC interface by default DefaultHttpRpcApis = strings.Join([]string{ api.DbApiName, api.EthApiName, api.NetApiName, api.Web3ApiName, - }, ",") + }, ",") ) type EthereumClient interface { @@ -36,6 +38,8 @@ type EthereumClient interface { Send(interface{}) error // Receive response Recv() (interface{}, error) + // List with modules this client supports + SupportedModules() (map[string]string, error) } func handle(conn net.Conn, api api.EthereumApi, c codec.Codec) { @@ -64,3 +68,22 @@ func handle(conn net.Conn, api api.EthereumApi, c codec.Codec) { } } } + +// Endpoint must be in the form of: +// ${protocol}:${path} +// e.g. ipc:/tmp/geth.ipc +// rpc:localhost:8545 +func ClientFromEndpoint(endpoint string, c codec.Codec) (EthereumClient, error) { + if strings.HasPrefix(endpoint, "ipc:") { + cfg := IpcConfig{ + Endpoint: endpoint[4:], + } + return NewIpcClient(cfg, codec.JSON) + } + + if strings.HasPrefix(endpoint, "rpc:") { + + } + + return nil, fmt.Errorf("Invalid endpoint") +} |