88: Correct functioning of unsafe_reset_all to mirror tendermint
This commit is contained in:
parent
029c0e9c72
commit
8daa916729
|
@ -1,13 +1,9 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
tmcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||
)
|
||||
|
||||
var UnsafeResetAllCmd = &cobra.Command{
|
||||
|
@ -17,9 +13,10 @@ var UnsafeResetAllCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
func unsafeResetAllCmd(cmd *cobra.Command, args []string) error {
|
||||
rootDir := viper.GetString(cli.HomeFlag)
|
||||
// wipe out rootdir if it exists before recreating it
|
||||
os.RemoveAll(rootDir)
|
||||
config.EnsureRoot(rootDir)
|
||||
cfg, err := getTendermintConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmcmd.ResetAll(cfg.DBDir(), cfg.PrivValidatorFile(), logger)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -122,14 +122,22 @@ func startBasecoinABCI(basecoinApp *app.Basecoin) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func startTendermint(dir string, basecoinApp *app.Basecoin) error {
|
||||
func getTendermintConfig() (*config.Config, error) {
|
||||
cfg := config.DefaultConfig()
|
||||
err := viper.Unmarshal(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
cfg.SetRoot(cfg.RootDir)
|
||||
config.EnsureRoot(cfg.RootDir)
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func startTendermint(dir string, basecoinApp *app.Basecoin) error {
|
||||
cfg, err := getTendermintConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: parse the log level from the config properly (multi modules)
|
||||
// but some tm code must be refactored for better usability
|
||||
|
|
Loading…
Reference in New Issue