diff options
author | Bas van Kervel <basvankervel@ziggo.nl> | 2015-06-08 16:23:54 +0800 |
---|---|---|
committer | Bas van Kervel <basvankervel@gmail.com> | 2015-06-11 20:01:39 +0800 |
commit | 2f55a1d79853c1348fb1a4332fff98110167da80 (patch) | |
tree | 66f35f10a3530072e35ff1ac1caa8edc5d5e8445 /rpc/api/utils.go | |
parent | 6609d45ef48ce1c2d2b0e73fa8fe5190d36e3920 (diff) | |
download | go-tangerine-2f55a1d79853c1348fb1a4332fff98110167da80.tar go-tangerine-2f55a1d79853c1348fb1a4332fff98110167da80.tar.gz go-tangerine-2f55a1d79853c1348fb1a4332fff98110167da80.tar.bz2 go-tangerine-2f55a1d79853c1348fb1a4332fff98110167da80.tar.lz go-tangerine-2f55a1d79853c1348fb1a4332fff98110167da80.tar.xz go-tangerine-2f55a1d79853c1348fb1a4332fff98110167da80.tar.zst go-tangerine-2f55a1d79853c1348fb1a4332fff98110167da80.zip |
restructured eth rpc API
Diffstat (limited to 'rpc/api/utils.go')
-rw-r--r-- | rpc/api/utils.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/rpc/api/utils.go b/rpc/api/utils.go new file mode 100644 index 000000000..76f00c251 --- /dev/null +++ b/rpc/api/utils.go @@ -0,0 +1,36 @@ +package api + +import ( + "strings" + + "fmt" + + "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/rpc/codec" + "github.com/ethereum/go-ethereum/xeth" +) + +const ( + EthApiName = "eth" +) + +// Parse a comma separated API string to individual api's +func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.Ethereum) ([]EthereumApi, error) { + if len(strings.TrimSpace(apistr)) == 0 { + return nil, fmt.Errorf("Empty apistr provided") + } + + names := strings.Split(apistr, ",") + apis := make([]EthereumApi, len(names)) + + for i, name := range names { + switch strings.ToLower(strings.TrimSpace(name)) { + case EthApiName: + apis[i] = NewEthApi(xeth, codec) + default: + return nil, fmt.Errorf("Unknown API '%s'", name) + } + } + + return apis, nil +} |