github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/upgrade/internal/keeper/keeper_ibc.go (about) 1 package keeper 2 3 import ( 4 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 5 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/upgrade/internal/types" 6 ) 7 8 // GetUpgradedConsensusState set the expected upgraded consensus state for the next version of this chain 9 func (k Keeper) GetUpgradedConsensusState(ctx sdk.Context, lastHeight int64) ([]byte, bool) { 10 store := ctx.KVStore(k.storeKey) 11 bz := store.Get(types.UpgradedConsStateKey(lastHeight)) 12 if len(bz) == 0 { 13 return nil, false 14 } 15 16 return bz, true 17 } 18 19 // ClearIBCState clears any planned IBC state 20 func (k Keeper) ClearIBCState(ctx sdk.Context, lastHeight int64) { 21 // delete IBC client and consensus state from store if this is IBC plan 22 store := ctx.KVStore(k.storeKey) 23 store.Delete(types.UpgradedClientKey(lastHeight)) 24 store.Delete(types.UpgradedConsStateKey(lastHeight)) 25 } 26 27 // GetUpgradedClient gets the expected upgraded client for the next version of this chain 28 func (k Keeper) GetUpgradedClient(ctx sdk.Context, height int64) ([]byte, bool) { 29 store := ctx.KVStore(k.storeKey) 30 bz := store.Get(types.UpgradedClientKey(height)) 31 if len(bz) == 0 { 32 return nil, false 33 } 34 35 return bz, true 36 } 37 38 // SetUpgradedClient sets the expected upgraded client for the next version of this chain at the last height the current chain will commit. 39 func (k Keeper) SetUpgradedClient(ctx sdk.Context, planHeight int64, bz []byte) error { 40 store := ctx.KVStore(k.storeKey) 41 store.Set(types.UpgradedClientKey(planHeight), bz) 42 return nil 43 } 44 45 // SetUpgradedConsensusState set the expected upgraded consensus state for the next version of this chain 46 // using the last height committed on this chain. 47 func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error { 48 store := ctx.KVStore(k.storeKey) 49 store.Set(types.UpgradedConsStateKey(planHeight), bz) 50 return nil 51 }