Skip to content

Commit

Permalink
Implement consumer removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Oct 25, 2022
1 parent 8ef0e58 commit 4830e7e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions x/ccv/provider/keeper/keymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,21 @@ func (s *KeyMapStore) IterateCcaToLastUpdateMemo(cb func(ConsumerConsAddr, ccvty
}
}

func (k Keeper) DeleteKeyMap(ctx sdk.Context, chainID string) {
store := ctx.KVStore(k.storeKey)
for _, pref := range [][]byte{
types.KeyMapPkToCkChainPrefix(chainID),
types.KeyMapCkToPkChainPrefix(chainID),
types.KeyMapCkToMemoChainPrefix(chainID),
} {
iter := sdk.KVStorePrefixIterator(store, pref)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())
}
}
}

func (k Keeper) KeyMap(ctx sdk.Context, chainID string) *KeyMap {
store := KeyMapStore{ctx.KVStore(k.storeKey), chainID}
km := MakeKeyMap(&store)
Expand Down
1 change: 1 addition & 0 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, lockUbd, clos
// clean up states
k.DeleteConsumerClientId(ctx, chainID)
k.DeleteConsumerGenesis(ctx, chainID)
k.DeleteKeyMap(ctx, chainID)
k.DeleteLockUnbondingOnTimeout(ctx, chainID)

// close channel and delete the mappings between chain ID and channel ID
Expand Down

0 comments on commit 4830e7e

Please sign in to comment.