mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
cmd/geth: close node.Node created with makeFullNode in cli commands
This commit is contained in:
parent
1fa065089b
commit
c1416b61ee
3 changed files with 10 additions and 2 deletions
|
|
@ -190,6 +190,7 @@ func initGenesis(ctx *cli.Context) error {
|
|||
}
|
||||
// Open an initialise both full and light databases
|
||||
stack := makeFullNode(ctx)
|
||||
defer stack.Close()
|
||||
for _, name := range []string{"chaindata", "lightchaindata"} {
|
||||
chaindb, err := stack.OpenDatabase(name, 0, 0)
|
||||
if err != nil {
|
||||
|
|
@ -209,6 +210,7 @@ func importChain(ctx *cli.Context) error {
|
|||
utils.Fatalf("This command requires an argument.")
|
||||
}
|
||||
stack := makeFullNode(ctx)
|
||||
defer stack.Close()
|
||||
chain, chainDb := utils.MakeChain(ctx, stack)
|
||||
defer chainDb.Close()
|
||||
|
||||
|
|
@ -303,6 +305,7 @@ func exportChain(ctx *cli.Context) error {
|
|||
utils.Fatalf("This command requires an argument.")
|
||||
}
|
||||
stack := makeFullNode(ctx)
|
||||
defer stack.Close()
|
||||
chain, _ := utils.MakeChain(ctx, stack)
|
||||
start := time.Now()
|
||||
|
||||
|
|
@ -336,6 +339,7 @@ func importPreimages(ctx *cli.Context) error {
|
|||
utils.Fatalf("This command requires an argument.")
|
||||
}
|
||||
stack := makeFullNode(ctx)
|
||||
defer stack.Close()
|
||||
diskdb := utils.MakeChainDatabase(ctx, stack).(*ethdb.LDBDatabase)
|
||||
|
||||
start := time.Now()
|
||||
|
|
@ -352,6 +356,7 @@ func exportPreimages(ctx *cli.Context) error {
|
|||
utils.Fatalf("This command requires an argument.")
|
||||
}
|
||||
stack := makeFullNode(ctx)
|
||||
defer stack.Close()
|
||||
diskdb := utils.MakeChainDatabase(ctx, stack).(*ethdb.LDBDatabase)
|
||||
|
||||
start := time.Now()
|
||||
|
|
@ -369,6 +374,7 @@ func copyDb(ctx *cli.Context) error {
|
|||
}
|
||||
// Initialize a new chain for the running node to sync into
|
||||
stack := makeFullNode(ctx)
|
||||
defer stack.Close()
|
||||
chain, chainDb := utils.MakeChain(ctx, stack)
|
||||
|
||||
syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode)
|
||||
|
|
@ -441,6 +447,7 @@ func removeDB(ctx *cli.Context) error {
|
|||
|
||||
func dump(ctx *cli.Context) error {
|
||||
stack := makeFullNode(ctx)
|
||||
defer stack.Close()
|
||||
chain, chainDb := utils.MakeChain(ctx, stack)
|
||||
for _, arg := range ctx.Args() {
|
||||
var block *types.Block
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func localConsole(ctx *cli.Context) error {
|
|||
// Create and start the node based on the CLI flags
|
||||
node := makeFullNode(ctx)
|
||||
startNode(ctx, node)
|
||||
defer node.Stop()
|
||||
defer node.Close()
|
||||
|
||||
// Attach to the newly started node and start the JavaScript console
|
||||
client, err := node.Attach()
|
||||
|
|
@ -180,7 +180,7 @@ func ephemeralConsole(ctx *cli.Context) error {
|
|||
// Create and start the node based on the CLI flags
|
||||
node := makeFullNode(ctx)
|
||||
startNode(ctx, node)
|
||||
defer node.Stop()
|
||||
defer node.Close()
|
||||
|
||||
// Attach to the newly started node and start the JavaScript console
|
||||
client, err := node.Attach()
|
||||
|
|
|
|||
|
|
@ -279,6 +279,7 @@ func geth(ctx *cli.Context) error {
|
|||
return fmt.Errorf("invalid command: %q", args[0])
|
||||
}
|
||||
node := makeFullNode(ctx)
|
||||
defer node.Close()
|
||||
startNode(ctx, node)
|
||||
node.Wait()
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue