genesis validator index setting

This commit is contained in:
rigelrozanski 2018-05-30 18:28:02 -07:00
parent e0b5118fce
commit 81e4a9797b
2 changed files with 11 additions and 2 deletions

View File

@ -33,9 +33,13 @@ func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) {
k.setPool(ctx, data.Pool) k.setPool(ctx, data.Pool)
k.setNewParams(ctx, data.Params) k.setNewParams(ctx, data.Params)
for _, validator := range data.Validators { for _, validator := range data.Validators {
k.updateValidator(ctx, validator)
// set validator
k.setValidator(ctx, validator)
// manually set indexes for the first time
k.setValidatorByPubKeyIndex(ctx, validator) k.setValidatorByPubKeyIndex(ctx, validator)
// manually set validator to bonded if necessary k.setValidatorByPowerIndex(ctx, validator, data.Pool)
if validator.Status() == sdk.Bonded { if validator.Status() == sdk.Bonded {
store.Set(GetValidatorsBondedKey(validator.PubKey), validator.Owner) store.Set(GetValidatorsBondedKey(validator.PubKey), validator.Owner)
} }

View File

@ -73,6 +73,11 @@ func (k Keeper) setValidatorByPubKeyIndex(ctx sdk.Context, validator Validator)
store.Set(GetValidatorByPubKeyIndexKey(validator.PubKey), validator.Owner) store.Set(GetValidatorByPubKeyIndexKey(validator.PubKey), validator.Owner)
} }
func (k Keeper) setValidatorByPowerIndex(ctx sdk.Context, validator Validator, pool Pool) {
store := ctx.KVStore(k.storeKey)
store.Set(GetValidatorsByPowerKey(validator, pool), validator.Owner)
}
// Get the set of all validators with no limits, used during genesis dump // Get the set of all validators with no limits, used during genesis dump
func (k Keeper) getAllValidators(ctx sdk.Context) (validators Validators) { func (k Keeper) getAllValidators(ctx sdk.Context) (validators Validators) {
store := ctx.KVStore(k.storeKey) store := ctx.KVStore(k.storeKey)