From 0194e1cc0c585ec08a409d4a12e906a0bd7b42f5 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Tue, 16 Jan 2018 21:37:01 -0500 Subject: [PATCH] Properly support datadir Former-commit-id: 80325290698bf7099f0e46cb48af46c9c197842a [formerly c036afc211c79e1134b4e42d5b79dd309d044eb4] Former-commit-id: c2d592d61e4dde4d762253048e07fe54ff48e0a3 --- sharding/client.go | 7 +++++-- sharding/vmc.go | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sharding/client.go b/sharding/client.go index 5fc919a7b..73ecaa5ec 100644 --- a/sharding/client.go +++ b/sharding/client.go @@ -1,6 +1,8 @@ package sharding import ( + "fmt" + "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/ethclient" @@ -22,10 +24,11 @@ type Client struct { } func MakeShardingClient(ctx *cli.Context) *Client { - endpoint := "" + path := node.DefaultDataDir() if ctx.GlobalIsSet(utils.DataDirFlag.Name) { - endpoint = ctx.GlobalString(utils.DataDirFlag.Name) + path = ctx.GlobalString(utils.DataDirFlag.Name) } + endpoint := fmt.Sprintf("%s/geth.ipc", path) config := &node.Config{ DataDir: "/tmp/ethereum", diff --git a/sharding/vmc.go b/sharding/vmc.go index 660620ef6..a2afdfa9c 100644 --- a/sharding/vmc.go +++ b/sharding/vmc.go @@ -28,9 +28,13 @@ func (c *Client) verifyVMC() error { log.Info(fmt.Sprintf("No validator management contract found at %s.", validatorManagerAddress.String())) accounts := c.keystore.Accounts() + if len(accounts) == 0 { + return fmt.Errorf("no accounts found") + } + // TODO: get password from file if err := c.keystore.Unlock(accounts[0], "password"); err != nil { - return err + return fmt.Errorf("failed to unlock account 0: %v", err) } suggestedGasPrice, err := c.client.SuggestGasPrice(context.Background())