Fix duplicated selectV1Keymanager (#6604)

* Fix duplicated selectV1Keymanager
This commit is contained in:
terence tsao 2020-07-14 18:05:33 -07:00 committed by GitHub
parent d7bcea7906
commit fe14c5086a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -178,6 +178,7 @@ contract in order to activate the validator client`,
if cliCtx.String(flags.KeyManager.Name) != "" {
pubKeysBytes48, success := node.ExtractPublicKeysFromKeymanager(
cliCtx,
nil, /* nil v1 keymanager */
nil, /* nil v2 keymanager */
)
pubKeys, err = bytesutil.FromBytes48Array(pubKeysBytes48), success

View File

@ -112,7 +112,7 @@ func NewValidatorClient(cliCtx *cli.Context) (*ValidatorClient, error) {
}
}
pubKeys, err := ExtractPublicKeysFromKeymanager(cliCtx, keyManagerV2)
pubKeys, err := ExtractPublicKeysFromKeymanager(cliCtx, keyManagerV1, keyManagerV2)
if err != nil {
return nil, err
}
@ -373,7 +373,7 @@ func clearDB(dataDir string, pubkeys [][48]byte, force bool) error {
}
// ExtractPublicKeysFromKeymanager extracts only the public keys from the specified key manager.
func ExtractPublicKeysFromKeymanager(cliCtx *cli.Context, keyManagerV2 v2.IKeymanager) ([][48]byte, error) {
func ExtractPublicKeysFromKeymanager(cliCtx *cli.Context, keyManagerV1 v1.KeyManager, keyManagerV2 v2.IKeymanager) ([][48]byte, error) {
var pubKeys [][48]byte
var err error
if featureconfig.Get().EnableAccountsV2 {
@ -383,9 +383,5 @@ func ExtractPublicKeysFromKeymanager(cliCtx *cli.Context, keyManagerV2 v2.IKeyma
}
return pubKeys, nil
}
km, err := selectV1Keymanager(cliCtx)
if err != nil {
return nil, err
}
return km.FetchValidatingKeys()
return keyManagerV1.FetchValidatingKeys()
}