Skip to content

Commit e62d445

Browse files
leonz789MaxMustermann2
authored andcommitted
fix: update cache when assetID updated in params (#214)
* fix: update cache when assetID updated in params * fix:update params with latest params when do recache * remove debug log
1 parent ce43d2e commit e62d445

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

x/oracle/keeper/params.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ func (k Keeper) RegisterNewTokenAndSetTokenFeeder(ctx sdk.Context, oInfo *types.
7373
if t.Name == oInfo.Token.Name && t.ChainID == chainID {
7474
t.AssetID = strings.Join([]string{t.AssetID, oInfo.AssetID}, ",")
7575
k.SetParams(ctx, p)
76+
if !ctx.IsCheckTx() {
77+
_ = GetAggregatorContext(ctx, k)
78+
cs.AddCache(cache.ItemP(p))
79+
}
7680
// there should have been existing tokenFeeder running(currently we register tokens from assets-module and with infinite endBlock)
7781
return nil
7882
}

x/oracle/keeper/single.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ func recacheAggregatorContext(ctx sdk.Context, agc *aggregator.AggregatorContext
153153
if updated := c.GetCache(&pRet); !updated {
154154
c.AddCache(cache.ItemP(*p))
155155
}
156+
// TODO: these 4 lines are mainly used for hot fix
157+
// since the latest params stored in KV for recache should be the same with the latest params, so these lines are just duplicated actions if everything is fine.
158+
*p = k.GetParams(ctx)
159+
agc.SetParams(p)
160+
setCommonParams(p)
161+
c.AddCache(cache.ItemP(*p))
156162

157163
return true
158164
}

0 commit comments

Comments
 (0)