Skip to content

Commit

Permalink
Fix InitGenesis bug for gauges
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon committed Dec 8, 2021
1 parent 442dd07 commit 97ac2a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions x/incentives/keeper/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ func (k Keeper) SetGaugeWithRefKey(ctx sdk.Context, gauge *types.Gauge) error {
if err := k.addGaugeRefByKey(ctx, combineKeys(types.KeyPrefixUpcomingGauges, timeKey), gauge.Id); err != nil {
return err
}
if err := k.addGaugeIDForDenom(ctx, gauge.Id, gauge.DistributeTo.Denom); err != nil {
return err
}
} else if gauge.IsActiveGauge(curTime) {
if err := k.addGaugeRefByKey(ctx, combineKeys(types.KeyPrefixActiveGauges, timeKey), gauge.Id); err != nil {
return err
}
if err := k.addGaugeIDForDenom(ctx, gauge.Id, gauge.DistributeTo.Denom); err != nil {
return err
}
} else {
if err := k.addGaugeRefByKey(ctx, combineKeys(types.KeyPrefixFinishedGauges, timeKey), gauge.Id); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion x/incentives/keeper/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (k Keeper) deleteGaugeRefByKey(ctx sdk.Context, key []byte, gaugeID uint64)
gaugeIDs := k.getGaugeRefs(ctx, key)
gaugeIDs, index := removeValue(gaugeIDs, gaugeID)
if index < 0 {
return fmt.Errorf("specific gauge with ID %d not found", gaugeID)
return fmt.Errorf("specific gauge with ID %d not found by reference %s", gaugeID, key)
}
if len(gaugeIDs) == 0 {
store.Delete(key)
Expand Down

0 comments on commit 97ac2a8

Please sign in to comment.