Merge remote-tracking branch 'origin/account-sync' into rpc-flags

This commit is contained in:
Roman Volosovskyi 2016-07-01 17:38:57 +03:00
commit ce2f2e7f8a
4 changed files with 12 additions and 10 deletions

View File

@ -10,7 +10,6 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/node"
errextra "github.com/pkg/errors"
)
@ -20,13 +19,13 @@ var (
)
// createAccount creates an internal geth account
func createAccount(password, keydir string) (string, string, error) {
func createAccount(password string) (string, string, error) {
if currentNode != nil {
var sync *[]node.Service
w := true
accman := accounts.NewManager(keydir, scryptN, scryptP, sync)
keydir := datadir + "/keystore"
accman := accounts.NewManager(keydir, scryptN, scryptP, &accountSync)
// generate the account
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
// node running locally
func createAndStartNode(datadir string) error {
func createAndStartNode(inputDir string) error {
currentNode = MakeNode(datadir)
currentNode = MakeNode(inputDir)
if currentNode != nil {
RunNode(currentNode)
return nil

View File

@ -19,7 +19,7 @@ func TestAccountBindings(t *testing.T) {
}
// create an account
address, _, err := createAccount("badpassword", ".ethereumtest/keystore")
address, _, err := createAccount("badpassword")
if err != nil {
fmt.Println(err.Error())
t.Error("Test failed: could not create account")

View File

@ -10,11 +10,11 @@ import (
var emptyError = ""
//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,
// 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
if err != nil {

View File

@ -32,6 +32,7 @@ var (
currentNode *node.Node // currently running 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
datadir string // data directory for geth
)
func main() {
@ -44,7 +45,9 @@ func main() {
}
// 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
set := flag.NewFlagSet("test", 0)