github.com/cosmos/cosmos-sdk@v0.50.10/x/slashing/keeper/migrations.go (about) 1 package keeper 2 3 import ( 4 "github.com/cosmos/cosmos-sdk/runtime" 5 sdk "github.com/cosmos/cosmos-sdk/types" 6 "github.com/cosmos/cosmos-sdk/x/slashing/exported" 7 v2 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v2" 8 v3 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v3" 9 v4 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v4" 10 ) 11 12 // Migrator is a struct for handling in-place store migrations. 13 type Migrator struct { 14 keeper Keeper 15 legacySubspace exported.Subspace 16 } 17 18 // NewMigrator returns a new Migrator. 19 func NewMigrator(keeper Keeper, ss exported.Subspace) Migrator { 20 return Migrator{keeper: keeper, legacySubspace: ss} 21 } 22 23 // Migrate1to2 migrates from version 1 to 2. 24 func (m Migrator) Migrate1to2(ctx sdk.Context) error { 25 return v2.MigrateStore(ctx, m.keeper.storeService) 26 } 27 28 // Migrate2to3 migrates the x/slashing module state from the consensus 29 // version 2 to version 3. Specifically, it takes the parameters that are currently stored 30 // and managed by the x/params modules and stores them directly into the x/slashing 31 // module state. 32 func (m Migrator) Migrate2to3(ctx sdk.Context) error { 33 store := runtime.KVStoreAdapter(m.keeper.storeService.OpenKVStore(ctx)) 34 return v3.Migrate(ctx, store, m.legacySubspace, m.keeper.cdc) 35 } 36 37 // Migrate3to4 migrates the x/slashing module state from the consensus 38 // version 3 to version 4. Specifically, it migrates the validator missed block 39 // bitmap. 40 func (m Migrator) Migrate3to4(ctx sdk.Context) error { 41 store := runtime.KVStoreAdapter(m.keeper.storeService.OpenKVStore(ctx)) 42 params, err := m.keeper.GetParams(ctx) 43 if err != nil { 44 return err 45 } 46 return v4.Migrate(ctx, m.keeper.cdc, store, params) 47 }