diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 562c7e0dee..e801ca3521 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -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 diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index 2500a969cf..d4443b3282 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -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() diff --git a/cmd/geth/main.go b/cmd/geth/main.go index dca02c82e4..17bf438e2a 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -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