Skip to content

Commit

Permalink
chore: try fix migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kioqq committed Dec 11, 2023
1 parent 1a3d5e6 commit d6ed9c9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
7 changes: 6 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,12 @@ func (app *Haqq) setupUpgradeHandlers() {
// v1.6.4 Coinomics v2
app.UpgradeKeeper.SetUpgradeHandler(
v164.UpgradeName,
v164.CreateUpgradeHandler(app.mm, app.configurator, app.GetKey(coinomicstypes.StoreKey), app.GetSubspace(coinomicstypes.ModuleName)),
v164.CreateUpgradeHandler(
app.mm,
app.configurator,
app.GetKey(coinomicstypes.StoreKey),
app.GetKey(paramstypes.StoreKey),
app.GetSubspace(coinomicstypes.ModuleName)),
)

// When a planned update height is reached, the old binary will panic
Expand Down
25 changes: 20 additions & 5 deletions app/upgrades/v1.6.4/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
storeKey storetypes.StoreKey,
paramsStoreKey storetypes.StoreKey,
paramsSubspace paramtypes.Subspace,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -28,6 +29,9 @@ func CreateUpgradeHandler(
iterator := sdk.KVStorePrefixIterator(store, nil)

for ; iterator.Valid(); iterator.Next() {
println("coinomics store key for delete")
println(string(iterator.Key()))

store.Delete(iterator.Key())
}

Expand All @@ -37,12 +41,23 @@ func CreateUpgradeHandler(
logger.Info("start cleaning params for module")

if paramsSubspace.HasKeyTable() {
paramsSubspace.IterateKeys(ctx, func(key []byte) bool {
println(string(key))
paramStore := ctx.KVStore(paramsStoreKey)
iteratorParams := sdk.KVStorePrefixIterator(paramStore, nil)

for ; iteratorParams.Valid(); iteratorParams.Next() {
println("params store key for delete")
println(string(iterator.Key()))
}

iterator.Close()

// paramsSubspace.WithKeyTable(paramtypes.NewKeyTable())
// // paramsSubspace.IterateKeys(ctx, func(key []byte) bool {
// // println(string(key))

paramsSubspace.Update(ctx, key, nil)
return false
})
// // paramsSubspace.Update(ctx, key, nil)
// // return false
// // })
}

// if !ps.HasKeyTable() {
Expand Down

0 comments on commit d6ed9c9

Please sign in to comment.