Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(distribution)!: use collections for ValidatorHistoricalRewards state #16607

Merged
merged 25 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove DeleteValidatorHistoricalRewards
  • Loading branch information
unknown unknown committed Jun 19, 2023
commit dcecfd38bdb24824d4394a1528bac7b63230827a
6 changes: 0 additions & 6 deletions x/distribution/keeper/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ func (k Keeper) SetValidatorHistoricalRewards(ctx context.Context, val sdk.ValAd
return k.ValidatorHistoricalRewards.Set(ctx, collections.Join(val, period), rewards)
}

// delete a historical reward
func (k Keeper) DeleteValidatorHistoricalReward(ctx context.Context, val sdk.ValAddress, period uint64) error {
store := k.storeService.OpenKVStore(ctx)
return store.Delete(types.GetValidatorHistoricalRewardsKey(val, period))
}

// delete historical rewards for a validator
func (k Keeper) DeleteValidatorHistoricalRewards(ctx context.Context, val sdk.ValAddress) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (k Keeper) decrementReferenceCount(ctx context.Context, valAddr sdk.ValAddr
}
historical.ReferenceCount--
if historical.ReferenceCount == 0 {
return k.DeleteValidatorHistoricalReward(ctx, valAddr, period)
return k.ValidatorHistoricalRewards.Remove(ctx, collections.Join(valAddr, period))
}

return k.SetValidatorHistoricalRewards(ctx, valAddr, period, historical)
Expand Down