Fix RPC error and change log statement

Former-commit-id: 54da8e259e6abae30c61dc6301cbfeeb0ede8570 [formerly 31f207fb38d4a1699dc60c294cf99a1673b54ab7]
Former-commit-id: c70fc84a836a6b03bcaf07b5fe7a9eb5c116e0da
This commit is contained in:
nisdas 2018-03-31 14:13:51 +08:00
parent 394adb4750
commit 9614c81228
3 changed files with 15 additions and 9 deletions

View File

@ -79,30 +79,28 @@ func MakeClient(ctx *cli.Context) *ShardingClient {
// Start the sharding client.
// * Connects to Geth node.
// * Verifies or deploys the sharding manager contract.
func (c *ShardingClient) Start() error {
log.Info("Starting collator client")
func (c *ShardingClient) Start() (*rpc.Client, error) {
rpcClient, err := dialRPC(c.endpoint)
if err != nil {
return err
return nil, fmt.Errorf("cannot start rpc client. %v", err)
}
c.client = ethclient.NewClient(rpcClient)
defer rpcClient.Close()
// Check account existence and unlock account before starting collator client
accounts := c.keystore.Accounts()
if len(accounts) == 0 {
return fmt.Errorf("no accounts found")
return nil, fmt.Errorf("no accounts found")
}
if err := c.unlockAccount(accounts[0]); err != nil {
return fmt.Errorf("cannot unlock account. %v", err)
return nil, fmt.Errorf("cannot unlock account. %v", err)
}
if err := initSMC(c); err != nil {
return err
return nil, err
}
return nil
return rpcClient, nil
}
// Wait until collator client is shutdown.

View File

@ -2,6 +2,7 @@ package collator
import (
"github.com/ethereum/go-ethereum/sharding/client"
"github.com/ethereum/go-ethereum/log"
cli "gopkg.in/urfave/cli.v1"
)
@ -12,7 +13,12 @@ func NewCollatorClient(ctx *cli.Context) *client.ShardingClient {
}
func CollatorStart(sclient *client.ShardingClient) error {
sclient.Start()
log.Info("Starting collator client")
rpcClient, err := sclient.Start()
defer rpcClient.Close()
if err != nil {
return err
}
if err := joinCollatorPool(sclient); err != nil {
return err

View File

@ -2,6 +2,7 @@ package proposer
import (
"github.com/ethereum/go-ethereum/sharding/client"
"github.com/ethereum/go-ethereum/log"
cli "gopkg.in/urfave/cli.v1"
)
@ -12,6 +13,7 @@ func NewProposerClient(ctx *cli.Context) *client.ShardingClient {
}
func ProposerStart(sclient *client.ShardingClient) error {
log.Info("Starting proposer client")
sclient.Start()
return nil