Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure DB Is Closed Before The Client Exit #476

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cmd/XDC/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ func exportChain(ctx *cli.Context) error {
utils.Fatalf("This command requires an argument.")
}
stack, _ := makeFullNode(ctx)
chain, _ := utils.MakeChain(ctx, stack)
chain, db := utils.MakeChain(ctx, stack)
defer db.Close()
start := time.Now()

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

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

start := time.Now()
if err := utils.ExportPreimages(diskdb, ctx.Args().First()); err != nil {
Expand All @@ -386,6 +389,7 @@ func copyDb(ctx *cli.Context) error {
// Initialize a new chain for the running node to sync into
stack, _ := makeFullNode(ctx)
chain, chainDb := utils.MakeChain(ctx, stack)
defer chainDb.Close()

syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode)
dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, nil, nil)
Expand Down Expand Up @@ -458,6 +462,8 @@ func removeDB(ctx *cli.Context) error {
func dump(ctx *cli.Context) error {
stack, _ := makeFullNode(ctx)
chain, chainDb := utils.MakeChain(ctx, stack)
defer chainDb.Close()

for _, arg := range ctx.Args() {
var block *types.Block
if hashish(arg) {
Expand All @@ -477,7 +483,6 @@ func dump(ctx *cli.Context) error {
fmt.Printf("%s\n", state.Dump())
}
}
chainDb.Close()
return nil
}

Expand Down