PrivValidator.GetAddress() and PrivValidator.GetPublicKey() return an

error instead of panic
This commit is contained in:
Ismail Khoffi
2018-11-29 18:52:19 +01:00
parent 44b769b1ac
commit 417c30b9c1
23 changed files with 345 additions and 151 deletions
+6 -2
View File
@@ -57,9 +57,13 @@ func initFilesWithConfig(config *cfg.Config) error {
GenesisTime: tmtime.Now(),
ConsensusParams: types.DefaultConsensusParams(),
}
key, err := pv.GetPubKey()
if err != nil {
return err
}
genDoc.Validators = []types.GenesisValidator{{
Address: pv.GetPubKey().Address(),
PubKey: pv.GetPubKey(),
Address: key.Address(),
PubKey: key,
Power: 10,
}}
+7 -1
View File
@@ -2,6 +2,7 @@ package commands
import (
"fmt"
"os"
"github.com/spf13/cobra"
@@ -17,6 +18,11 @@ var ShowValidatorCmd = &cobra.Command{
func showValidator(cmd *cobra.Command, args []string) {
privValidator := privval.LoadOrGenFilePV(config.PrivValidatorFile())
pubKeyJSONBytes, _ := cdc.MarshalJSON(privValidator.GetPubKey())
key, err := privValidator.GetPubKey()
if err != nil {
fmt.Fprintf(os.Stderr, "Could not read public key from FilePV %v", privValidator)
os.Exit(1)
}
pubKeyJSONBytes, _ := cdc.MarshalJSON(key)
fmt.Println(string(pubKeyJSONBytes))
}
+6 -2
View File
@@ -90,9 +90,13 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
pvFile := filepath.Join(nodeDir, config.BaseConfig.PrivValidator)
pv := privval.LoadFilePV(pvFile)
pubKey, err := pv.GetPubKey()
if err != nil {
return err
}
genVals[i] = types.GenesisValidator{
Address: pv.GetPubKey().Address(),
PubKey: pv.GetPubKey(),
Address: pubKey.Address(),
PubKey: pubKey,
Power: 1,
Name: nodeDirName,
}