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

@ -45,11 +45,6 @@ var (
testKey = flag.String("key", defaultTestKey, "Private key of a test account to inject")
)
var (
ethereumServiceId = "ethereum"
whisperServiceId = "whisper"
)
func main() {
flag.Parse()
@ -131,11 +126,11 @@ func MakeSystemNode(keydir string, privkey string, test *tests.BlockTest) (*node
TestGenesisBlock: test.Genesis,
AccountManager: accman,
}
if err := stack.Register(ethereumServiceId, func(ctx *node.ServiceContext) (node.Service, error) { return eth.New(ctx, ethConf) }); err != nil {
if err := stack.Register("ethereum", func(ctx *node.ServiceContext) (node.Service, error) { return eth.New(ctx, ethConf) }); err != nil {
return nil, err
}
// Initialize and register the Whisper protocol
if err := stack.Register(whisperServiceId, func(*node.ServiceContext) (node.Service, error) { return whisper.New(), nil }); err != nil {
if err := stack.Register("whisper", func(*node.ServiceContext) (node.Service, error) { return whisper.New(), nil }); err != nil {
return nil, err
}
return stack, nil
@ -144,7 +139,9 @@ func MakeSystemNode(keydir string, privkey string, test *tests.BlockTest) (*node
// RunTest executes the specified test against an already pre-configured protocol
// stack to ensure basic checks pass before running RPC tests.
func RunTest(stack *node.Node, test *tests.BlockTest) error {
blockchain := stack.Service(ethereumServiceId).(*eth.Ethereum).BlockChain()
var ethereum *eth.Ethereum
stack.SingletonService(&ethereum)
blockchain := ethereum.BlockChain()
// Process the blocks and verify the imported headers
blocks, err := test.TryBlocksInsert(blockchain)