Skip to content

Commit

Permalink
Merge pull request #1742 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
ensure db is closed before exit
  • Loading branch information
ucwong authored Sep 27, 2023
2 parents d8d649e + e1c2075 commit 0f90d82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/cortex/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ func exportChain(ctx *cli.Context) error {
utils.Fatalf("This command requires an argument.")
}
stack := makeFullNode(ctx)
chain, _ := utils.MakeChain(ctx, stack, true)
chain, db := utils.MakeChain(ctx, stack, true)
defer db.Close()
start := time.Now()

var err error
Expand Down Expand Up @@ -371,6 +372,7 @@ func importPreimages(ctx *cli.Context) error {
}
stack := makeFullNode(ctx)
diskdb := utils.MakeChainDatabase(ctx, stack, false).(ctxcdb.Database)
defer diskdb.Close()

start := time.Now()
if err := utils.ImportPreimages(diskdb, ctx.Args().First()); err != nil {
Expand All @@ -387,6 +389,7 @@ func exportPreimages(ctx *cli.Context) error {
}
stack := makeFullNode(ctx)
diskdb := utils.MakeChainDatabase(ctx, stack, false).(ctxcdb.Database)
defer diskdb.Close()

start := time.Now()
if err := utils.ExportPreimages(diskdb, ctx.Args().First()); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cmd/cortex/verkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func verifyVerkle(ctx *cli.Context) error {
defer stack.Close()

chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close()
headBlock := rawdb.ReadHeadBlock(chaindb)
if headBlock == nil {
log.Error("Failed to load head block")
Expand Down Expand Up @@ -168,6 +169,7 @@ func expandVerkle(ctx *cli.Context) error {
defer stack.Close()

chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close()
var (
rootC common.Hash
keylist [][]byte
Expand Down

0 comments on commit 0f90d82

Please sign in to comment.