From 97ac2a86303fc8966a4c169107e0945775107e67 Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Wed, 8 Dec 2021 17:57:46 -0400 Subject: [PATCH] Fix InitGenesis bug for gauges --- x/incentives/keeper/gauge.go | 6 ++++++ x/incentives/keeper/store.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index 682ebdb2962..23601e32aea 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -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 diff --git a/x/incentives/keeper/store.go b/x/incentives/keeper/store.go index 99a9a11ed50..c0ebe186ed4 100644 --- a/x/incentives/keeper/store.go +++ b/x/incentives/keeper/store.go @@ -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)