Skip to content

Commit

Permalink
Merge pull request #186 from kokeshiM0chi/select_val_key
Browse files Browse the repository at this point in the history
feat: add an option for selecting priv key type to `unsafe_reset_all`, `unsafe_reset_priv_validator`, and `gen_validator`
  • Loading branch information
Kynea0b authored Feb 17, 2021
2 parents e46b547 + 4c50f8d commit 0f86e4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/tendermint/commands/gen_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ var GenValidatorCmd = &cobra.Command{
Run: genValidator,
}

func init() {
GenValidatorCmd.Flags().String("priv_key_type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
}

func genValidator(cmd *cobra.Command, args []string) {
pv, _ := privval.GenFilePV("", "", privval.PrivKeyTypeEd25519)
pv, _ := privval.GenFilePV("", "", config.PrivKeyType)
jsbz, err := cdc.MarshalJSON(pv)
if err != nil {
panic(err)
Expand Down
6 changes: 5 additions & 1 deletion cmd/tendermint/commands/reset_priv_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var keepAddrBook bool

func init() {
ResetAllCmd.Flags().BoolVar(&keepAddrBook, "keep-addr-book", false, "Keep the address book intact")
ResetAllCmd.Flags().String("priv_key_type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
ResetPrivValidatorCmd.Flags().String("priv_key_type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
}

// ResetPrivValidatorCmd resets the private validator files.
Expand All @@ -35,7 +39,7 @@ var ResetPrivValidatorCmd = &cobra.Command{
// it's only suitable for testnets.
func resetAll(cmd *cobra.Command, args []string) {
ResetAll(config.DBDir(), config.P2P.AddrBookFile(), config.PrivValidatorKeyFile(),
config.PrivValidatorKeyType(), config.PrivValidatorStateFile(), logger)
config.PrivValidatorStateFile(), config.PrivValidatorKeyType(), logger)
}

// XXX: this is totally unsafe.
Expand Down

0 comments on commit 0f86e4c

Please sign in to comment.