Skip to content

Commit

Permalink
Fix merge-bug: cmd: make reset more safe (backport #8081) (#8089)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnasu committed Apr 5, 2022
1 parent 686a624 commit 90a0e80
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/ostracon/commands/reset_priv_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func resetAll(dbDir, addrBookFile, privValKeyFile, privValStateFile, privKeyType
logger.Error("Error removing all blockchain history", "dir", dbDir, "err", err)
}

// recreate the dbDir since the privVal state needs to live there
if err := tmos.EnsureDir(dbDir, 0700); err != nil {
logger.Error("unable to recreate dbDir", "err", err)
}
resetFilePV(privValKeyFile, privValStateFile, privKeyType, logger)
return nil
}
Expand Down Expand Up @@ -157,7 +161,9 @@ func resetFilePV(privValKeyFile, privValStateFile, privKeyType string, logger lo
if err != nil {
return err
}
pv.Save()
if pv != nil {
pv.Save()
}
logger.Info("Generated private validator file", "keyFile", privValKeyFile,
"stateFile", privValStateFile)
}
Expand Down

0 comments on commit 90a0e80

Please sign in to comment.