mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-29 18:40:34 +00:00
Added unsafe_reset_priv_validator
This commit is contained in:
@@ -40,6 +40,8 @@ Commands:
|
||||
gen_tx()
|
||||
case "probe_upnp":
|
||||
probe_upnp()
|
||||
case "unsafe_reset_priv_validator":
|
||||
reset_priv_validator()
|
||||
default:
|
||||
fmt.Printf("Unknown command %v\n", args[0])
|
||||
}
|
||||
|
||||
29
cmd/tendermint/reset_priv_validator.go
Normal file
29
cmd/tendermint/reset_priv_validator.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user