-
Notifications
You must be signed in to change notification settings - Fork 1
/
v2_to_v3.go
35 lines (31 loc) · 1.01 KB
/
v2_to_v3.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package migrations
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
/**
* No `dex` state exists in any public chain at the time this data type update happened.
* Any new chain (including local ones) should be based on a Sei version newer than this update
* and therefore doesn't need this migration
*/
func DataTypeUpdate(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error {
ClearStore(ctx, storeKey)
return nil
}
/**
* CAUTION: this function clears up the entire `dex` module store, so it should only ever
* be used outside of a production setting.
*/
func ClearStore(ctx sdk.Context, storeKey sdk.StoreKey) {
for i := 0; i < 256; i++ {
clearStoreForByte(ctx, storeKey, byte(i))
}
}
func clearStoreForByte(ctx sdk.Context, storeKey sdk.StoreKey, b byte) {
store := ctx.KVStore(storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte{b})
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
store.Delete(iterator.Key())
}
}