cmd, node, p2p/simulations: fix node account manager leak (#19004)
* node: close AccountsManager in new Close method * p2p/simulations, p2p/simulations/adapters: handle node close on shutdown * node: move node ephemeralKeystore cleanup to stop method * node: call Stop in Node.Close method * cmd/geth: close node.Node created with makeFullNode in cli commands * node: close Node instances in tests * cmd/geth, node: minor code style fixes * cmd, console, miner, mobile: proper node Close() termination
This commit is contained in:
committed by
Péter Szilágyi
parent
81801ccc2b
commit
26aea73673
@@ -172,6 +172,12 @@ type SimNode struct {
|
||||
registerOnce sync.Once
|
||||
}
|
||||
|
||||
// Close closes the underlaying node.Node to release
|
||||
// acquired resources.
|
||||
func (sn *SimNode) Close() error {
|
||||
return sn.node.Close()
|
||||
}
|
||||
|
||||
// Addr returns the node's discovery address
|
||||
func (sn *SimNode) Addr() []byte {
|
||||
return []byte(sn.Node().String())
|
||||
|
@@ -22,6 +22,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -569,6 +570,12 @@ func (net *Network) Shutdown() {
|
||||
if err := node.Stop(); err != nil {
|
||||
log.Warn("Can't stop node", "id", node.ID(), "err", err)
|
||||
}
|
||||
// If the node has the close method, call it.
|
||||
if closer, ok := node.Node.(io.Closer); ok {
|
||||
if err := closer.Close(); err != nil {
|
||||
log.Warn("Can't close node", "id", node.ID(), "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
close(net.quitc)
|
||||
}
|
||||
|
Reference in New Issue
Block a user