Skip to content

Commit 1bd08aa

Browse files
committed
remove staking queue when farming disabled
1 parent 9810197 commit 1bd08aa

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

x/farming/keeper/epoch.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ func (k Keeper) RemoveFromCurrentEpochStakingQueue(ctx sdk.Context, staking *typ
8282
store.Delete(types.CurrentEpochStakingQueueByAddressKey(staking.Address, staking.Id))
8383
}
8484

85+
// RemoveCurrentEpochStakingQueue removes the staking queue for the current epoch
86+
func (k Keeper) RemoveCurrentEpochStakingQueue(ctx sdk.Context) {
87+
k.IterateCurrentEpochStakingQueue(ctx, func(staking *types.Staking) (stop bool) {
88+
// remove from the staking queue for the current epoch
89+
k.RemoveFromCurrentEpochStakingQueue(ctx, staking)
90+
91+
return false
92+
})
93+
}
94+
8595
// HasStakingForCurrentEpoch returns true if the given staking exists for the current epoch, false otherwise
8696
func (k Keeper) HasStakingForCurrentEpoch(ctx sdk.Context, stakingId uint64) bool {
8797
store := ctx.KVStore(k.storeKey)

x/farming/keeper/params.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ func (k Keeper) OnParamsChanged(ctx sdk.Context, params types.Params, newParams
5656
// start the new epoch when farming enabled or re-enabled
5757
k.NewEpoch(ctx)
5858
} else if params.Enabled && !newParams.Enabled {
59-
// terminate the current epoch if disabled
59+
// remove the staking queue for the current epoch
60+
k.RemoveCurrentEpochStakingQueue(ctx)
61+
62+
// end the current epoch
6063
currentEpoch := k.GetCurrentEpoch(ctx)
6164
currentEpoch.Status = types.EpochStatus_EPOCH_STATUS_ENDED
6265
k.SetEpoch(ctx, currentEpoch)

0 commit comments

Comments
 (0)