mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 13:58:09 -05:00
Fixed deferring of closing dbs (#5982)
* fixed deferring of closing dbs * removed unnecessary slice pointer * Merge branch 'master' into merge-defer-fix * Merge branch 'master' into merge-defer-fix
This commit is contained in:
@@ -224,6 +224,13 @@ func HandleEmptyKeystoreFlags(cliCtx *cli.Context, confirmPassword bool) (string
|
||||
// Merge merges data from validator databases in sourceDirectories into a new store, which is created in targetDirectory.
|
||||
func Merge(ctx context.Context, sourceDirectories []string, targetDirectory string) error {
|
||||
var sourceStores []*db.Store
|
||||
defer func() {
|
||||
for _, store := range sourceStores {
|
||||
if err := store.Close(); err != nil {
|
||||
err = errors.Wrapf(err, "Failed to close the database in %s", store.DatabasePath())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
for _, dir := range sourceDirectories {
|
||||
store, err := db.GetKVStore(dir)
|
||||
@@ -245,14 +252,6 @@ func Merge(ctx context.Context, sourceDirectories []string, targetDirectory stri
|
||||
return errors.Wrapf(err, "Failed to merge validator databases into %s", targetDirectory)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
for _, store := range sourceStores {
|
||||
if err := store.Close(); err != nil {
|
||||
err = errors.Wrapf(err, "Failed to close the database in %s", store.DatabasePath())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user