more cwgoes updates
This commit is contained in:
parent
d442fc5fa9
commit
4cbf253c14
|
@ -167,8 +167,8 @@ func (k Keeper) removeValidator(ctx sdk.Context, address sdk.Address) {
|
|||
store.Delete(GetValidatorKey(address))
|
||||
store.Delete(GetValidatorsBondedByPowerKey(validator, pool))
|
||||
|
||||
// delete from current and power weighted validator groups if the validator
|
||||
// exists and add validator with zero power to the validator updates
|
||||
// delete from the current and power weighted validator groups if the validator
|
||||
// is bonded - and add validator with zero power to the validator updates
|
||||
if store.Get(GetValidatorsBondedKey(validator.PubKey)) == nil {
|
||||
return
|
||||
}
|
||||
|
@ -190,6 +190,11 @@ func (k Keeper) GetValidatorsBonded(ctx sdk.Context) (validators []Validator) {
|
|||
iterator := store.SubspaceIterator(ValidatorsBondedKey)
|
||||
i := 0
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
|
||||
// sanity check
|
||||
if i > int(maxValidators-1) {
|
||||
panic("maxValidators is less than the number of records in ValidatorsBonded Store, store should have been updated")
|
||||
}
|
||||
bz := iterator.Value()
|
||||
var validator Validator
|
||||
k.cdc.MustUnmarshalBinary(bz, &validator)
|
||||
|
@ -276,7 +281,7 @@ func (k Keeper) updateBondedValidators(ctx sdk.Context, store sdk.KVStore, pool
|
|||
if found {
|
||||
|
||||
// remove from ToKickOut group
|
||||
toKickOut[string(validator.Address)] = nil
|
||||
delete(toKickOut, string(validator.Address))
|
||||
} else {
|
||||
|
||||
// if it wasn't in the toKickOut group it means
|
||||
|
@ -299,9 +304,6 @@ func (k Keeper) updateBondedValidators(ctx sdk.Context, store sdk.KVStore, pool
|
|||
|
||||
// perform the actual kicks
|
||||
for _, value := range toKickOut {
|
||||
if value == nil {
|
||||
continue
|
||||
}
|
||||
var validator Validator
|
||||
k.cdc.MustUnmarshalBinary(value, &validator)
|
||||
k.unbondValidator(ctx, store, validator)
|
||||
|
@ -336,6 +338,9 @@ func (k Keeper) unbondValidator(ctx sdk.Context, store sdk.KVStore, validator Va
|
|||
// perform all the store operations for when a validator status becomes bonded
|
||||
func (k Keeper) bondValidator(ctx sdk.Context, store sdk.KVStore, validator Validator, pool Pool) Validator {
|
||||
|
||||
// first delete the old record in the pool
|
||||
store.Delete(GetValidatorsBondedByPowerKey(validator, pool))
|
||||
|
||||
// set the status
|
||||
validator.Status = sdk.Bonded
|
||||
validator, pool = validator.UpdateSharesLocation(pool)
|
||||
|
@ -343,7 +348,6 @@ func (k Keeper) bondValidator(ctx sdk.Context, store sdk.KVStore, validator Vali
|
|||
|
||||
// save the now bonded validator record to the three referened stores
|
||||
bzVal := k.cdc.MustMarshalBinary(validator)
|
||||
store.Delete(GetValidatorsBondedByPowerKey(validator, pool))
|
||||
store.Set(GetValidatorKey(validator.Address), bzVal)
|
||||
store.Set(GetValidatorsBondedByPowerKey(validator, pool), bzVal)
|
||||
store.Set(GetValidatorsBondedKey(validator.PubKey), bzVal)
|
||||
|
|
|
@ -134,6 +134,7 @@ func (s PoolShares) Tokens(p Pool) sdk.Rat {
|
|||
return p.unbondedShareExRate().Mul(s.Amount)
|
||||
case ShareUnbonded:
|
||||
return p.unbondedShareExRate().Mul(s.Amount)
|
||||
default:
|
||||
panic("unknown share kind")
|
||||
}
|
||||
return sdk.ZeroRat()
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ prefixed areas of the staking store which are accessed in `x/stake/keeper.go`.
|
|||
## Validators
|
||||
- Prefix Key Space: ValidatorsKey
|
||||
- Key/Sort: Validator Owner Address
|
||||
- Contains: All Validator records whether independent of being bonded or not
|
||||
- Contains: All Validator records independent of being bonded or not
|
||||
- Used For: Retrieve validator from owner address, general validator retrieval
|
||||
|
||||
## Validators By Power
|
||||
- Prefix Key Space: ValidatorsByPowerKey
|
||||
- Key/Sort: Validator Power (equivalent bonded shares) then Block
|
||||
Height then Transaction Order
|
||||
- Contains: All Validator records whether independent of being bonded or not
|
||||
- Contains: All Validator records independent of being bonded or not
|
||||
- Used For: Determining who the top validators are whom should be bonded
|
||||
|
||||
## Validators Bonded
|
||||
|
@ -30,4 +30,5 @@ prefixed areas of the staking store which are accessed in `x/stake/keeper.go`.
|
|||
- Prefix Key Space: TendermintUpdatesKey
|
||||
- Key/Sort: Validator Owner Address
|
||||
- Contains: Validators are queued to affect the consensus validation set in Tendermint
|
||||
- Used For: Informing Tendermint of the validator set updates
|
||||
- Used For: Informing Tendermint of the validator set updates, is used only intra-block, as the
|
||||
updates are applied then cleared on endblock
|
||||
|
|
Loading…
Reference in New Issue