Update naming (BondedValidatorIndex->ValidatorsBondedIndex) and add some comments
This commit is contained in:
parent
c88fc481d4
commit
3fa5778921
@ -77,6 +77,7 @@ func (k Keeper) WithdrawDelegationReward(ctx sdk.Context, delegatorAddr sdk.AccA
|
||||
return types.ErrNoDelegationDistInfo(k.codespace)
|
||||
}
|
||||
|
||||
// TODO: Reconcile with duplicate code in getDelegatorRewardsAll.
|
||||
height := ctx.BlockHeight()
|
||||
bondedTokens := k.stakeKeeper.TotalPower(ctx)
|
||||
feePool := k.GetFeePool(ctx)
|
||||
@ -125,6 +126,7 @@ func (k Keeper) getDelegatorRewardsAll(ctx sdk.Context, delAddr sdk.AccAddress,
|
||||
bondedTokens := k.stakeKeeper.TotalPower(ctx)
|
||||
|
||||
// iterate over all the delegations
|
||||
// TODO: Reconcile with duplicate code in WithdrawDelegationReward.
|
||||
operationAtDelegation := func(_ int64, del sdk.Delegation) (stop bool) {
|
||||
feePool := k.GetFeePool(ctx)
|
||||
valAddr := del.GetValidator()
|
||||
|
||||
@ -61,7 +61,7 @@ func GetValidatorsByPowerIndexKey(validator types.Validator, pool types.Pool) []
|
||||
}
|
||||
|
||||
// get the bonded validator index key for an operator address
|
||||
func GetBondedValidatorIndexKey(operator sdk.ValAddress) []byte {
|
||||
func GetValidatorsBondedIndexKey(operator sdk.ValAddress) []byte {
|
||||
return append(ValidatorsBondedIndexKey, operator...)
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,11 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
)
|
||||
|
||||
// Apply and return accumulated updates to the bonded validator set
|
||||
// Apply and return accumulated updates to the bonded validator set. Also,
|
||||
// * Updates the active bonded valset as keyed by GetValidatorsBondedIndexKey().
|
||||
// * Updates validator status' according to updated powers.
|
||||
// * Updates the fee pool bonded vs loose tokens.
|
||||
// * Updates relevant indices.
|
||||
//
|
||||
// CONTRACT: Only validators with non-zero power or zero-power that were bonded
|
||||
// at the previous block height or were removed from the validator set entirely
|
||||
@ -21,7 +25,9 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
maxValidators := k.GetParams(ctx).MaxValidators
|
||||
|
||||
// retrieve last validator set
|
||||
// Retrieve the last validator set.
|
||||
// This persistent set is updated later in this function.
|
||||
// (see GetValidatorsBondedIndexKey()).
|
||||
last := k.retrieveLastValidatorSet(ctx)
|
||||
|
||||
// iterate over validators, highest power to lowest
|
||||
@ -73,7 +79,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab
|
||||
delete(last, operatorBytes)
|
||||
|
||||
// set the bonded validator index
|
||||
store.Set(GetBondedValidatorIndexKey(operator), newPowerBytes)
|
||||
store.Set(GetValidatorsBondedIndexKey(operator), newPowerBytes)
|
||||
|
||||
// keep count
|
||||
count++
|
||||
@ -98,7 +104,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab
|
||||
}
|
||||
|
||||
// delete from the bonded validator index
|
||||
store.Delete(GetBondedValidatorIndexKey(operator))
|
||||
store.Delete(GetValidatorsBondedIndexKey(operator))
|
||||
|
||||
// update the validator set
|
||||
updates = append(updates, validator.ABCIValidatorUpdateZero())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user