cmd, common, core, eth, node, rpc, tests, whisper, xeth: use protocol stacks

This commit is contained in:
Péter Szilágyi
2015-11-17 18:33:25 +02:00
parent 8a44451edf
commit 1e806c4c77
30 changed files with 1051 additions and 949 deletions

View File

@ -22,6 +22,7 @@ import (
"fmt"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
"github.com/ethereum/go-ethereum/xeth"
@ -154,7 +155,7 @@ var (
)
// Parse a comma separated API string to individual api's
func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.Ethereum) ([]shared.EthereumApi, error) {
func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, stack *node.Node) ([]shared.EthereumApi, error) {
if len(strings.TrimSpace(apistr)) == 0 {
return nil, fmt.Errorf("Empty apistr provided")
}
@ -162,10 +163,16 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
names := strings.Split(apistr, ",")
apis := make([]shared.EthereumApi, len(names))
var eth *eth.Ethereum
if stack != nil {
if _, err := stack.SingletonService(&eth); err != nil {
return nil, err
}
}
for i, name := range names {
switch strings.ToLower(strings.TrimSpace(name)) {
case shared.AdminApiName:
apis[i] = NewAdminApi(xeth, eth, codec)
apis[i] = NewAdminApi(xeth, stack, codec)
case shared.DebugApiName:
apis[i] = NewDebugApi(xeth, eth, codec)
case shared.DbApiName:
@ -188,7 +195,6 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
return nil, fmt.Errorf("Unknown API '%s'", name)
}
}
return apis, nil
}