Separate validator pub key index updates
This commit is contained in:
parent
0324be4189
commit
7e9192f513
|
@ -35,6 +35,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) {
|
|||
// Staking assumes bonded validators are already stored, need to force update
|
||||
validator.PoolShares.Status = sdk.Unbonded
|
||||
k.setValidator(ctx, validator)
|
||||
k.setValidatorByPubKeyIndex(ctx, validator)
|
||||
k.updateValidator(ctx, validator)
|
||||
}
|
||||
for _, bond := range data.Bonds {
|
||||
|
|
|
@ -55,6 +55,7 @@ func handleMsgDeclareCandidacy(ctx sdk.Context, msg MsgDeclareCandidacy, k Keepe
|
|||
|
||||
validator := NewValidator(msg.ValidatorAddr, msg.PubKey, msg.Description)
|
||||
k.setValidator(ctx, validator)
|
||||
k.setValidatorByPubKeyIndex(ctx, validator)
|
||||
tags := sdk.NewTags(
|
||||
"action", []byte("declareCandidacy"),
|
||||
"validator", msg.ValidatorAddr.Bytes(),
|
||||
|
|
|
@ -65,6 +65,10 @@ func (k Keeper) setValidator(ctx sdk.Context, validator Validator) {
|
|||
// set main store
|
||||
bz := k.cdc.MustMarshalBinary(validator)
|
||||
store.Set(GetValidatorKey(validator.Owner), bz)
|
||||
}
|
||||
|
||||
func (k Keeper) setValidatorByPubKeyIndex(ctx sdk.Context, validator Validator) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
// set pointer by pubkey
|
||||
store.Set(GetValidatorByPubKeyIndexKey(validator.PubKey), validator.Owner)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue