From e8cad948e366cd1d0a9ebef642073f4ade9899e9 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 21 Apr 2017 12:54:53 -0400 Subject: [PATCH] cli: ResetAll doesnt depend on cobra --- .../commands/reset_priv_validator.go | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/tendermint/commands/reset_priv_validator.go b/cmd/tendermint/commands/reset_priv_validator.go index 5e3172a5..b1fb334b 100644 --- a/cmd/tendermint/commands/reset_priv_validator.go +++ b/cmd/tendermint/commands/reset_priv_validator.go @@ -5,13 +5,15 @@ import ( "github.com/spf13/cobra" + cfg "github.com/tendermint/go-config" + "github.com/tendermint/log15" "github.com/tendermint/tendermint/types" ) var resetAllCmd = &cobra.Command{ Use: "unsafe_reset_all", Short: "(unsafe) Remove all the data and WAL, reset this node's validator", - Run: ResetAll, + Run: resetAll, } var resetPrivValidatorCmd = &cobra.Command{ @@ -27,15 +29,23 @@ func init() { // XXX: this is totally unsafe. // it's only suitable for testnets. -func ResetAll(cmd *cobra.Command, args []string) { - resetPrivValidator(cmd, args) - os.RemoveAll(config.GetString("db_dir")) - os.Remove(config.GetString("cs_wal_file")) +func resetAll(cmd *cobra.Command, args []string) { + ResetAll(config, log) } // XXX: this is totally unsafe. // it's only suitable for testnets. 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 var privValidator *types.PrivValidator privValidatorFile := config.GetString("priv_validator_file")