aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/utils.go
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@ziggo.nl>2015-06-08 18:43:58 +0800
committerBas van Kervel <basvankervel@gmail.com>2015-06-11 20:01:39 +0800
commita1a475fb9296e214292840d89811123292c7953c (patch)
treebe92dc0faa0f62276fbb6b1fef529cec8280a12c /rpc/api/utils.go
parent2a0d888326036be9cabe6680617ce2d1a27761d3 (diff)
downloadgo-tangerine-a1a475fb9296e214292840d89811123292c7953c.tar
go-tangerine-a1a475fb9296e214292840d89811123292c7953c.tar.gz
go-tangerine-a1a475fb9296e214292840d89811123292c7953c.tar.bz2
go-tangerine-a1a475fb9296e214292840d89811123292c7953c.tar.lz
go-tangerine-a1a475fb9296e214292840d89811123292c7953c.tar.xz
go-tangerine-a1a475fb9296e214292840d89811123292c7953c.tar.zst
go-tangerine-a1a475fb9296e214292840d89811123292c7953c.zip
added console command
Diffstat (limited to 'rpc/api/utils.go')
-rw-r--r--rpc/api/utils.go47
1 files changed, 2 insertions, 45 deletions
diff --git a/rpc/api/utils.go b/rpc/api/utils.go
index a62058140..7024365e4 100644
--- a/rpc/api/utils.go
+++ b/rpc/api/utils.go
@@ -8,11 +8,6 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/xeth"
- "github.com/ethereum/go-ethereum/rpc/shared"
-)
-
-const (
- EthApiName = "eth"
)
// Parse a comma separated API string to individual api's
@@ -28,6 +23,8 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
switch strings.ToLower(strings.TrimSpace(name)) {
case EthApiName:
apis[i] = NewEthApi(xeth, codec)
+ case Web3ApiName:
+ apis[i] = NewWeb3(xeth, codec)
default:
return nil, fmt.Errorf("Unknown API '%s'", name)
}
@@ -35,43 +32,3 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
return apis, nil
}
-
-// combines multiple API's
-type mergedApi struct {
- apis map[string]EthereumApi
-}
-
-// create new merged api instance
-func newMergedApi(apis ...EthereumApi) *mergedApi {
- mergedApi := new(mergedApi)
- mergedApi.apis = make(map[string]EthereumApi)
-
- for _, api := range apis {
- for _, method := range api.Methods() {
- mergedApi.apis[method] = api
- }
- }
- return mergedApi
-}
-
-// Supported RPC methods
-func (self *mergedApi) Methods() []string {
- all := make([]string, len(self.apis))
- for method, _ := range self.apis {
- all = append(all, method)
- }
- return all
-}
-
-// Call the correct API's Execute method for the given request
-func (self *mergedApi) Execute(req *shared.Request) (interface{}, error) {
- if api, found := self.apis[req.Method]; found {
- return api.Execute(req)
- }
- return nil, shared.NewNotImplementedError(req.Method)
-}
-
-// Merge multiple API's to a single API instance
-func Merge(apis ...EthereumApi) EthereumApi {
- return newMergedApi(apis...)
-}