aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/comms/comms.go
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/comms/comms.go')
-rw-r--r--rpc/comms/comms.go27
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")
+}