Skip to content

Commit

Permalink
Merge PR #2292: x/staking: Use variable names in switch case
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored and cwgoes committed Sep 11, 2018
1 parent 4f0c3cb commit 2e0fc15
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions x/stake/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ func (k Keeper) UpdateValidator(ctx sdk.Context, validator types.Validator) type
validator.BondHeight, validator.BondIntraTxCounter = k.bondIncrement(ctx, oldFound, oldValidator, validator)
valPower := k.updateValidatorPower(ctx, oldFound, oldValidator, validator, pool)
cliffPower := k.GetCliffValidatorPower(ctx)
cliffValExists := (cliffPower != nil)
var valPowerLTcliffPower bool
if cliffValExists {
valPowerLTcliffPower = (bytes.Compare(valPower, cliffPower) == -1)
}

switch {

Expand All @@ -256,22 +261,21 @@ func (k Keeper) UpdateValidator(ctx sdk.Context, validator types.Validator) type
bz := k.cdc.MustMarshalBinary(validator.ABCIValidator())
store.Set(GetTendermintUpdatesKey(validator.OperatorAddr), bz)

if cliffPower != nil {
if cliffValExists {
cliffAddr := sdk.ValAddress(k.GetCliffValidator(ctx))
if bytes.Equal(cliffAddr, validator.OperatorAddr) {
k.updateCliffValidator(ctx, validator)
}
}

// if is a new validator and the new power is less than the cliff validator
case cliffPower != nil && !oldFound &&
bytes.Compare(valPower, cliffPower) == -1: //(valPower < cliffPower
case cliffValExists && !oldFound && valPowerLTcliffPower:
// skip to completion

// if was unbonded and the new power is less than the cliff validator
case cliffPower != nil &&
case cliffValExists &&
(oldFound && oldValidator.Status == sdk.Unbonded) &&
bytes.Compare(valPower, cliffPower) == -1: //(valPower < cliffPower
valPowerLTcliffPower: //(valPower < cliffPower
// skip to completion

default:
Expand Down

0 comments on commit 2e0fc15

Please sign in to comment.