mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 05:41:21 +00:00
cli: ResetAll doesnt depend on cobra
This commit is contained in:
@ -5,13 +5,15 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
cfg "github.com/tendermint/go-config"
|
||||||
|
"github.com/tendermint/log15"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var resetAllCmd = &cobra.Command{
|
var resetAllCmd = &cobra.Command{
|
||||||
Use: "unsafe_reset_all",
|
Use: "unsafe_reset_all",
|
||||||
Short: "(unsafe) Remove all the data and WAL, reset this node's validator",
|
Short: "(unsafe) Remove all the data and WAL, reset this node's validator",
|
||||||
Run: ResetAll,
|
Run: resetAll,
|
||||||
}
|
}
|
||||||
|
|
||||||
var resetPrivValidatorCmd = &cobra.Command{
|
var resetPrivValidatorCmd = &cobra.Command{
|
||||||
@ -27,15 +29,23 @@ func init() {
|
|||||||
|
|
||||||
// XXX: this is totally unsafe.
|
// XXX: this is totally unsafe.
|
||||||
// it's only suitable for testnets.
|
// it's only suitable for testnets.
|
||||||
func ResetAll(cmd *cobra.Command, args []string) {
|
func resetAll(cmd *cobra.Command, args []string) {
|
||||||
resetPrivValidator(cmd, args)
|
ResetAll(config, log)
|
||||||
os.RemoveAll(config.GetString("db_dir"))
|
|
||||||
os.Remove(config.GetString("cs_wal_file"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: this is totally unsafe.
|
// XXX: this is totally unsafe.
|
||||||
// it's only suitable for testnets.
|
// it's only suitable for testnets.
|
||||||
func resetPrivValidator(cmd *cobra.Command, args []string) {
|
func resetPrivValidator(cmd *cobra.Command, args []string) {
|
||||||
|
ResetPrivValidator(config, log)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exported so other CLI tools can use it
|
||||||
|
func ResetAll(c cfg.Config, l log15.Logger) {
|
||||||
|
ResetPrivValidator(c, l)
|
||||||
|
os.RemoveAll(c.GetString("db_dir"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResetPrivValidator(c cfg.Config, l log15.Logger) {
|
||||||
// Get PrivValidator
|
// Get PrivValidator
|
||||||
var privValidator *types.PrivValidator
|
var privValidator *types.PrivValidator
|
||||||
privValidatorFile := config.GetString("priv_validator_file")
|
privValidatorFile := config.GetString("priv_validator_file")
|
||||||
|
Reference in New Issue
Block a user