Browse Source

return an error on `show_validator` (#3316)

* return a command error prior to init

* add a pending log entry

* Update CHANGELOG_PENDING.md

Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com>

closes: #3314
pull/3323/head
Alexander Bezobchuk 6 years ago
committed by Anton Kaliaev
parent
commit
cf737ec85c
3 changed files with 22 additions and 8 deletions
  1. +5
    -1
      CHANGELOG_PENDING.md
  2. +1
    -2
      cmd/tendermint/commands/show_node_id.go
  3. +16
    -5
      cmd/tendermint/commands/show_validator.go

+ 5
- 1
CHANGELOG_PENDING.md View File

@ -21,5 +21,9 @@ Special thanks to external contributors on this release:
### IMPROVEMENTS:
### BUG FIXES:
- [consensus] \#3297 Flush WAL on stop to prevent data corruption during
* [consensus] \#3297 Flush WAL on stop to prevent data corruption during
graceful shutdown
* [cmd] \#3314 Return an
error on `show_validator` when the private validator file does not exist.

+ 1
- 2
cmd/tendermint/commands/show_node_id.go View File

@ -16,12 +16,11 @@ var ShowNodeIDCmd = &cobra.Command{
}
func showNodeID(cmd *cobra.Command, args []string) error {
nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile())
if err != nil {
return err
}
fmt.Println(nodeKey.ID())
fmt.Println(nodeKey.ID())
return nil
}

+ 16
- 5
cmd/tendermint/commands/show_validator.go View File

@ -5,6 +5,7 @@ import (
"github.com/spf13/cobra"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/privval"
)
@ -12,11 +13,21 @@ import (
var ShowValidatorCmd = &cobra.Command{
Use: "show_validator",
Short: "Show this node's validator info",
Run: showValidator,
RunE: showValidator,
}
func showValidator(cmd *cobra.Command, args []string) {
privValidator := privval.LoadOrGenFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile())
pubKeyJSONBytes, _ := cdc.MarshalJSON(privValidator.GetPubKey())
fmt.Println(string(pubKeyJSONBytes))
func showValidator(cmd *cobra.Command, args []string) error {
keyFilePath := config.PrivValidatorKeyFile()
if !cmn.FileExists(keyFilePath) {
return fmt.Errorf("private validator file %s does not exist", keyFilePath)
}
pv := privval.LoadFilePV(keyFilePath, config.PrivValidatorStateFile())
bz, err := cdc.MarshalJSON(pv.GetPubKey())
if err != nil {
return err
}
fmt.Println(string(bz))
return nil
}

Loading…
Cancel
Save