mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
node: call Stop in Node.Close method
This commit is contained in:
parent
b4ac1d1c68
commit
1fa065089b
1 changed files with 20 additions and 2 deletions
22
node/node.go
22
node/node.go
|
|
@ -121,9 +121,27 @@ func New(conf *Config) (*Node, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
// Close releases resources acquired in Node constructor New.
|
||||
// Close stops the Node and releases resources acquired in
|
||||
// Node constructor New.
|
||||
func (n *Node) Close() error {
|
||||
return n.accman.Close()
|
||||
var errs []error
|
||||
|
||||
// Terminate all subsystems and collect any errors
|
||||
if err := n.Stop(); err != nil && err != ErrNodeStopped {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if err := n.accman.Close(); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
// Report any errors that might have occurred
|
||||
switch len(errs) {
|
||||
case 0:
|
||||
return nil
|
||||
case 1:
|
||||
return errs[0]
|
||||
default:
|
||||
return fmt.Errorf("%v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
// Register injects a new service into the node's stack. The service created by
|
||||
|
|
|
|||
Loading…
Reference in a new issue