Properly support datadir

Former-commit-id: 80325290698bf7099f0e46cb48af46c9c197842a [formerly c036afc211c79e1134b4e42d5b79dd309d044eb4]
Former-commit-id: c2d592d61e4dde4d762253048e07fe54ff48e0a3
This commit is contained in:
Preston Van Loon 2018-01-16 21:37:01 -05:00
parent 92a48ed5a7
commit 0194e1cc0c
2 changed files with 10 additions and 3 deletions

View File

@ -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",

View File

@ -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())