fix type and account manager in-memory object

This commit is contained in:
Adrian Tiberius 2016-07-04 19:16:18 +03:00
parent 72b84b05f8
commit 64edf2ddf2
3 changed files with 5 additions and 49 deletions

View File

@ -9,10 +9,6 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/p2p/discover"
errextra "github.com/pkg/errors"
@ -30,20 +26,6 @@ func createAccount(password string) (string, string, error) {
w := true
// Retrieve the AccountManager
var ethereum *eth.FullNodeService
var accountManager *accounts.Manager
if err := currentNode.Service(&ethereum); err == nil {
accountManager = ethereum.ApiBackend.AccountManager()
} else {
var ethereum *les.LightNodeService
if err := currentNode.Service(&ethereum); err == nil {
accountManager = ethereum.ApiBackend.AccountManager()
} else {
glog.V(logger.Warn).Infoln("cannot get account manager:", err)
}
}
if accountManager != nil {
// generate the account
account, err := accountManager.NewAccount(password, w)
@ -80,20 +62,6 @@ func unlockAccount(address, password string, seconds int) error {
if currentNode != nil {
// Retrieve the AccountManager
var ethereum *eth.FullNodeService
var accountManager *accounts.Manager
if err := currentNode.Service(&ethereum); err == nil {
accountManager = ethereum.ApiBackend.AccountManager()
} else {
var ethereum *les.LightNodeService
if err := currentNode.Service(&ethereum); err == nil {
accountManager = ethereum.ApiBackend.AccountManager()
} else {
glog.V(logger.Warn).Infoln("cannot get account manager:", err)
}
}
if accountManager != nil {
account, err := utils.MakeAddress(accountManager, address)
if err != nil {

View File

@ -97,6 +97,7 @@ func call(chatId *C.char, path *C.char, params *C.char) *C.char {
//export initJail
func initJail(js *C.char) {
Init(C.GoString(js))
}
//export addPeer
func addPeer(url *C.char) *C.char {

View File

@ -8,8 +8,6 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/node"
@ -78,21 +76,6 @@ func MakeNode(inputDir string) *node.Node {
utils.DebugSetup(c)
currentNode, accountSync = utils.MakeSystemNode(clientIdentifier, vString, rConfig, makeDefaultExtra(), c)
// Retrieve the AccountManager
// doesn't work because node not started yet ... maybe use some kind of event when node started
// and then get account managet and also signal the event to the app
var ethereum *eth.FullNodeService
if err := currentNode.Service(&ethereum); err == nil {
accountManager = ethereum.ApiBackend.AccountManager()
} else {
var ethereum *les.LightNodeService
if err := currentNode.Service(&ethereum); err == nil {
accountManager = ethereum.ApiBackend.AccountManager()
} else {
glog.V(logger.Warn).Infoln("cannot get account manager:", err)
}
}
return currentNode
}
@ -100,6 +83,10 @@ func MakeNode(inputDir string) *node.Node {
// StartNode starts a geth node entity
func RunNode(nodeIn *node.Node) {
utils.StartNode(nodeIn)
if err := nodeIn.Service(&accountManager); err != nil {
glog.V(logger.Warn).Infoln("cannot get account manager:", err)
}
nodeIn.Wait()
}