cli/server: close the chain gracefully on restore even on error

Not an issue for dumper, but when restoring we should correctly save
everything already imported even if the subsequent block fails.
This commit is contained in:
Roman Khimov 2019-12-27 12:38:07 +03:00
parent 1f4b7b366e
commit f15a2401b1

View file

@ -233,6 +233,9 @@ func restoreDB(ctx *cli.Context) error {
if err != nil {
return err
}
defer chain.Close()
defer prometheus.ShutDown()
defer pprof.ShutDown()
var allBlocks = reader.ReadU32LE()
if reader.Err != nil {
@ -271,9 +274,6 @@ func restoreDB(ctx *cli.Context) error {
return cli.NewExitError(fmt.Errorf("failed to add block %d: %s", i, err), 1)
}
}
pprof.ShutDown()
prometheus.ShutDown()
chain.Close()
return nil
}