Skip to content

Commit

Permalink
final touch
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Oct 31, 2024
1 parent 84e4d54 commit a2a7b36
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,28 @@ func (app *InitiaApp) RegisterUpgradeHandlers(cfg module.Configurator) {

err = app.MoveKeeper.VMStore.Walk(ctx, new(collections.Range[[]byte]).Descending(), func(key, value []byte) (stop bool, err error) {
key = bytes.Clone(key)
value = bytes.Clone(value)

cursor := movetypes.AddressBytesLength
if len(key) <= cursor {
return true, fmt.Errorf("invalid key length: %d", len(key))
}

separator := key[cursor]

if separator == movetypes.ModuleSeparator {
checksum := movetypes.ModuleBzToChecksum(value)
value = checksum[:]
} else if separator >= movetypes.TableInfoSeparator {
return true, errors.New("unknown prefix")
} else {
err = app.MoveKeeper.VMStore.Remove(ctx, bytes.Clone(key))
if err != nil {
return true, err
}
} else if err = app.MoveKeeper.VMStore.Remove(ctx, key); err != nil {
return true, err
}

key[cursor] = key[cursor] + 1
err = app.MoveKeeper.VMStore.Set(ctx, key, value)
if err != nil {
return true, err
}

return false, nil
})
if err != nil {
Expand Down

0 comments on commit a2a7b36

Please sign in to comment.