node: remove dependency on wallet backend packages (#23019)
* accounts: new AddBackends method in manager * node,cmd/geth: mv accman backend init to cmd/geth * node,cmd/geth: mv scrypt config downstreawm from node * accounts: use static buffer size for accman sub chan minor fix * accounts,cmd/geth: update accman backends through its event loop * accounts,node: add comments * accounts: un-export newBackendEvent * accounts: use chan instead of wg in newBlockEvent * node: rename isKeyDirEphem * accounts,cmd: AddBackends->AddBackend * accounts: fix potential blocking when adding backend
This commit is contained in:
23
node/node.go
23
node/node.go
@ -42,7 +42,8 @@ type Node struct {
|
||||
config *Config
|
||||
accman *accounts.Manager
|
||||
log log.Logger
|
||||
ephemKeystore string // if non-empty, the key directory that will be removed by Stop
|
||||
keyDir string // key store directory
|
||||
keyDirTemp bool // If true, key directory will be removed by Stop
|
||||
dirLock fileutil.Releaser // prevents concurrent use of instance directory
|
||||
stop chan struct{} // Channel to wait for termination notifications
|
||||
server *p2p.Server // Currently running P2P networking layer
|
||||
@ -112,14 +113,15 @@ func New(conf *Config) (*Node, error) {
|
||||
if err := node.openDataDir(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Ensure that the AccountManager method works before the node has started. We rely on
|
||||
// this in cmd/geth.
|
||||
am, ephemeralKeystore, err := makeAccountManager(conf)
|
||||
keyDir, isEphem, err := getKeyStoreDir(conf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node.accman = am
|
||||
node.ephemKeystore = ephemeralKeystore
|
||||
node.keyDir = keyDir
|
||||
node.keyDirTemp = isEphem
|
||||
// Creates an empty AccountManager with no backends. Callers (e.g. cmd/geth)
|
||||
// are required to add the backends later on.
|
||||
node.accman = accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: conf.InsecureUnlockAllowed})
|
||||
|
||||
// Initialize the p2p server. This creates the node key and discovery databases.
|
||||
node.server.Config.PrivateKey = node.config.NodeKey()
|
||||
@ -233,8 +235,8 @@ func (n *Node) doClose(errs []error) error {
|
||||
if err := n.accman.Close(); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if n.ephemKeystore != "" {
|
||||
if err := os.RemoveAll(n.ephemKeystore); err != nil {
|
||||
if n.keyDirTemp {
|
||||
if err := os.RemoveAll(n.keyDir); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
@ -514,6 +516,11 @@ func (n *Node) InstanceDir() string {
|
||||
return n.config.instanceDir()
|
||||
}
|
||||
|
||||
// KeyStoreDir retrieves the key directory
|
||||
func (n *Node) KeyStoreDir() string {
|
||||
return n.keyDir
|
||||
}
|
||||
|
||||
// AccountManager retrieves the account manager used by the protocol stack.
|
||||
func (n *Node) AccountManager() *accounts.Manager {
|
||||
return n.accman
|
||||
|
Reference in New Issue
Block a user