Remove reliance on default Signer
This change allows the default privValidator to use a custom Signer implementation with no reliance on the default Signer implementation.
This commit is contained in:
parent
bf5e956087
commit
7e4a704bd1
|
@ -35,8 +35,12 @@ func main() {
|
|||
rootCmd.AddCommand(tc.TestnetFilesCmd)
|
||||
rootCmd.AddCommand(tc.VersionCmd)
|
||||
|
||||
privValidator := types.LoadOrGenPrivValidator(config.PrivValidatorFile(), logger)
|
||||
privValidator.SetSigner(types.NewDefaultSigner(privValidator.PrivKey))
|
||||
// Override with HSM implementation, otherwise nil will trigger default
|
||||
// software signer:
|
||||
var signer types.Signer = nil
|
||||
|
||||
privValidator := types.LoadPrivValidatorWithSigner(config.PrivValidatorFile(),
|
||||
signer)
|
||||
rootCmd.AddCommand(tc.NewRunNodeCmd(privValidator))
|
||||
|
||||
cmd := cli.PrepareBaseCmd(rootCmd, "TM", os.ExpandEnv("$HOME/.tendermint"))
|
||||
|
|
|
@ -112,6 +112,10 @@ func GenPrivValidator() *PrivValidator {
|
|||
}
|
||||
|
||||
func LoadPrivValidator(filePath string) *PrivValidator {
|
||||
return LoadPrivValidatorWithSigner(filePath, nil)
|
||||
}
|
||||
|
||||
func LoadPrivValidatorWithSigner(filePath string, signer Signer) *PrivValidator {
|
||||
privValJSONBytes, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
Exit(err.Error())
|
||||
|
@ -123,7 +127,11 @@ func LoadPrivValidator(filePath string) *PrivValidator {
|
|||
}
|
||||
|
||||
privVal.filePath = filePath
|
||||
privVal.Signer = NewDefaultSigner(privVal.PrivKey)
|
||||
if signer == nil {
|
||||
privVal.Signer = NewDefaultSigner(privVal.PrivKey)
|
||||
} else {
|
||||
privVal.Signer = signer
|
||||
}
|
||||
privVal.setPubKeyAndAddress()
|
||||
return &privVal
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue