fix datadir for account create, and account sync
This commit is contained in:
parent
9c472f9599
commit
2241ceccd4
|
@ -10,7 +10,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
|
||||||
errextra "github.com/pkg/errors"
|
errextra "github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,13 +19,13 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// createAccount creates an internal geth account
|
// createAccount creates an internal geth account
|
||||||
func createAccount(password, keydir string) (string, string, error) {
|
func createAccount(password string) (string, string, error) {
|
||||||
|
|
||||||
if currentNode != nil {
|
if currentNode != nil {
|
||||||
|
|
||||||
var sync *[]node.Service
|
|
||||||
w := true
|
w := true
|
||||||
accman := accounts.NewManager(keydir, scryptN, scryptP, sync)
|
keydir := datadir + "/keystore"
|
||||||
|
accman := accounts.NewManager(keydir, scryptN, scryptP, &accountSync)
|
||||||
|
|
||||||
// generate the account
|
// generate the account
|
||||||
account, err := accman.NewAccount(password, w)
|
account, err := accman.NewAccount(password, w)
|
||||||
|
@ -82,9 +81,9 @@ func unlockAccount(address, password string, seconds int) error {
|
||||||
|
|
||||||
// createAndStartNode creates a node entity and starts the
|
// createAndStartNode creates a node entity and starts the
|
||||||
// node running locally
|
// node running locally
|
||||||
func createAndStartNode(datadir string) error {
|
func createAndStartNode(inputDir string) error {
|
||||||
|
|
||||||
currentNode = MakeNode(datadir)
|
currentNode = MakeNode(inputDir)
|
||||||
if currentNode != nil {
|
if currentNode != nil {
|
||||||
RunNode(currentNode)
|
RunNode(currentNode)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -19,7 +19,7 @@ func TestAccountBindings(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an account
|
// create an account
|
||||||
address, _, err := createAccount("badpassword", ".ethereumtest/keystore")
|
address, _, err := createAccount("badpassword")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
t.Error("Test failed: could not create account")
|
t.Error("Test failed: could not create account")
|
||||||
|
|
|
@ -10,11 +10,11 @@ import (
|
||||||
var emptyError = ""
|
var emptyError = ""
|
||||||
|
|
||||||
//export CreateAccount
|
//export CreateAccount
|
||||||
func CreateAccount(password, keydir *C.char) *C.char {
|
func CreateAccount(password *C.char) *C.char {
|
||||||
|
|
||||||
// This is equivalent to creating an account from the command line,
|
// This is equivalent to creating an account from the command line,
|
||||||
// just modified to handle the function arg passing
|
// just modified to handle the function arg passing
|
||||||
address, pubKey, err := createAccount(C.GoString(password), C.GoString(keydir))
|
address, pubKey, err := createAccount(C.GoString(password))
|
||||||
|
|
||||||
errString := emptyError
|
errString := emptyError
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -32,6 +32,7 @@ var (
|
||||||
currentNode *node.Node // currently running geth node
|
currentNode *node.Node // currently running geth node
|
||||||
c *cli.Context // the CLI context used to start the geth node
|
c *cli.Context // the CLI context used to start the geth node
|
||||||
accountSync []node.Service // the object used to sync accounts between geth services
|
accountSync []node.Service // the object used to sync accounts between geth services
|
||||||
|
datadir string // data directory for geth
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -44,7 +45,9 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeNode create a geth node entity
|
// MakeNode create a geth node entity
|
||||||
func MakeNode(datadir string) *node.Node {
|
func MakeNode(inputDir string) *node.Node {
|
||||||
|
|
||||||
|
datadir = inputDir
|
||||||
|
|
||||||
// TODO remove admin rpcapi flag
|
// TODO remove admin rpcapi flag
|
||||||
set := flag.NewFlagSet("test", 0)
|
set := flag.NewFlagSet("test", 0)
|
||||||
|
|
Loading…
Reference in New Issue