Browse Source

Added unsafe_reset_priv_validator

pull/57/head
Jae Kwon 10 years ago
parent
commit
99a040998f
2 changed files with 31 additions and 0 deletions
  1. +2
    -0
      cmd/tendermint/main.go
  2. +29
    -0
      cmd/tendermint/reset_priv_validator.go

+ 2
- 0
cmd/tendermint/main.go View File

@ -40,6 +40,8 @@ Commands:
gen_tx() gen_tx()
case "probe_upnp": case "probe_upnp":
probe_upnp() probe_upnp()
case "unsafe_reset_priv_validator":
reset_priv_validator()
default: default:
fmt.Printf("Unknown command %v\n", args[0]) fmt.Printf("Unknown command %v\n", args[0])
} }


+ 29
- 0
cmd/tendermint/reset_priv_validator.go View File

@ -0,0 +1,29 @@
package main
import (
"os"
"github.com/tendermint/tendermint/config"
sm "github.com/tendermint/tendermint/state"
)
// NOTE: this is totally unsafe.
// it's only suitable for testnets.
func reset_priv_validator() {
// Get PrivValidator
var privValidator *sm.PrivValidator
privValidatorFile := config.App().GetString("PrivValidatorFile")
if _, err := os.Stat(privValidatorFile); err == nil {
privValidator = sm.LoadPrivValidator(privValidatorFile)
privValidator.LastHeight = 0
privValidator.LastRound = 0
privValidator.LastStep = 0
privValidator.Save()
log.Info("Reset PrivValidator", "file", privValidatorFile)
} else {
privValidator = sm.GenPrivValidator()
privValidator.SetFile(privValidatorFile)
privValidator.Save()
log.Info("Generated PrivValidator", "file", privValidatorFile)
}
}

Loading…
Cancel
Save