Panic on revoke/unrevoke nonexistent validator

This commit is contained in:
Christopher Goes 2018-05-29 02:27:43 +02:00
parent aed5d94b1c
commit 0dae7f8e4c
No known key found for this signature in database
GPG Key ID: E828D98232D328D3
1 changed files with 2 additions and 6 deletions

View File

@ -799,9 +799,7 @@ func (k Keeper) Revoke(ctx sdk.Context, pubkey crypto.PubKey) {
logger := ctx.Logger().With("module", "x/stake")
val, found := k.GetValidatorByPubKey(ctx, pubkey)
if !found {
// TODO Should we panic?
ctx.Logger().Info("Validator with pubkey %s not found, cannot revoke", pubkey)
return
panic(fmt.Errorf("Validator with pubkey %s not found, cannot revoke", pubkey))
}
val.Revoked = true
k.updateValidator(ctx, val) // update the validator, now revoked
@ -814,9 +812,7 @@ func (k Keeper) Unrevoke(ctx sdk.Context, pubkey crypto.PubKey) {
logger := ctx.Logger().With("module", "x/stake")
val, found := k.GetValidatorByPubKey(ctx, pubkey)
if !found {
// TODO Should we panic?
ctx.Logger().Info("Validator with pubkey %s not found, cannot unrevoke", pubkey)
return
panic(fmt.Errorf("Validator with pubkey %s not found, cannot unrevoke", pubkey))
}
val.Revoked = false
k.updateValidator(ctx, val) // update the validator, now unrevoked