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(incentives): remove redundant param from CreateGaugeRefKeys (backport #6511) #6516

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### API Breaks

* [#6487](https://github.com/osmosis-labs/osmosis/pull/6487) make PoolModuleI CalculateSpotPrice API return BigDec
<<<<<<< HEAD
=======
* [#6511](https://github.com/osmosis-labs/osmosis/pull/6511) remove redundant param from CreateGaugeRefKeys in incentives
* [#6510](https://github.com/osmosis-labs/osmosis/pull/6510) remove redundant ctx param from DeleteAllKeysFromPrefix in osmoutils
>>>>>>> 1e83ec9e (refactor(incentives): remove redundant param from CreateGaugeRefKeys (#6511))
Comment on lines +53 to +57
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in the next PR


## v19.1.0

Expand Down
15 changes: 8 additions & 7 deletions x/incentives/keeper/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ func (k Keeper) setGauge(ctx sdk.Context, gauge *types.Gauge) error {
// CreateGaugeRefKeys takes combinedKey (the keyPrefix for upcoming, active, or finished gauges combined with gauge start time) and adds a reference to the respective gauge ID.
// If gauge is active or upcoming, creates reference between the denom and gauge ID.
// Used to consolidate codepaths for InitGenesis and CreateGauge.
func (k Keeper) CreateGaugeRefKeys(ctx sdk.Context, gauge *types.Gauge, combinedKeys []byte, activeOrUpcomingGauge bool) error {
func (k Keeper) CreateGaugeRefKeys(ctx sdk.Context, gauge *types.Gauge, combinedKeys []byte) error {
if err := k.addGaugeRefByKey(ctx, combinedKeys, gauge.Id); err != nil {
return err
}

activeOrUpcomingGauge := gauge.IsActiveGauge(ctx.BlockTime()) || gauge.IsUpcomingGauge(ctx.BlockTime())

if activeOrUpcomingGauge {
if err := k.addGaugeIDForDenom(ctx, gauge.Id, gauge.DistributeTo.Denom); err != nil {
return err
Expand All @@ -81,17 +84,16 @@ func (k Keeper) SetGaugeWithRefKey(ctx sdk.Context, gauge *types.Gauge) error {

curTime := ctx.BlockTime()
timeKey := getTimeKey(gauge.StartTime)
activeOrUpcomingGauge := gauge.IsActiveGauge(curTime) || gauge.IsUpcomingGauge(curTime)

if gauge.IsUpcomingGauge(curTime) {
combinedKeys := combineKeys(types.KeyPrefixUpcomingGauges, timeKey)
return k.CreateGaugeRefKeys(ctx, gauge, combinedKeys, activeOrUpcomingGauge)
return k.CreateGaugeRefKeys(ctx, gauge, combinedKeys)
} else if gauge.IsActiveGauge(curTime) {
combinedKeys := combineKeys(types.KeyPrefixActiveGauges, timeKey)
return k.CreateGaugeRefKeys(ctx, gauge, combinedKeys, activeOrUpcomingGauge)
return k.CreateGaugeRefKeys(ctx, gauge, combinedKeys)
} else {
combinedKeys := combineKeys(types.KeyPrefixFinishedGauges, timeKey)
return k.CreateGaugeRefKeys(ctx, gauge, combinedKeys, activeOrUpcomingGauge)
return k.CreateGaugeRefKeys(ctx, gauge, combinedKeys)
}
}

Expand Down Expand Up @@ -199,9 +201,8 @@ func (k Keeper) CreateGauge(ctx sdk.Context, isPerpetual bool, owner sdk.AccAddr
k.SetLastGaugeID(ctx, gauge.Id)

combinedKeys := combineKeys(types.KeyPrefixUpcomingGauges, getTimeKey(gauge.StartTime))
activeOrUpcomingGauge := true

err = k.CreateGaugeRefKeys(ctx, &gauge, combinedKeys, activeOrUpcomingGauge)
err = k.CreateGaugeRefKeys(ctx, &gauge, combinedKeys)
if err != nil {
return 0, err
}
Expand Down