Closed
Description
opened on May 29, 2019
Summary
Create iterator functions for gov keepers
Problem Definition
Currently gov iterators are duplicated and defined within each function in the governance keeper. For eg:
// Deletes all the deposits on a specific proposal without refunding them
func (keeper Keeper) DeleteDeposits(ctx sdk.Context, proposalID uint64) {
store := ctx.KVStore(keeper.storeKey)
depositsIterator := keeper.GetDeposits(ctx, proposalID)
defer depositsIterator.Close()
for ; depositsIterator.Valid(); depositsIterator.Next() {
deposit := &Deposit{}
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), deposit)
err := keeper.sk.BurnCoins(ctx, ModuleName, deposit.Amount)
if err != nil {
panic(err)
}
store.Delete(depositsIterator.Key())
}
}
Proposal
Define the following iterators:
func (k Keeper) IterateProposals(ctx sdk.Context, fn func(proposalID uint64) (stop bool))
func (k Keeper) IterateRedelegations(ctx sdk.Context, fn func(proposalID uint64, depositorAddr sdk.AccAddress) (stop bool))
func (k Keeper) IterateRedelegations(ctx sdk.Context, fn func(proposalID uint64, voterAddr sdk.AccAddress) (stop bool))
For Admin Use
- Not duplicate issue
- Appropriate labels applied
- Appropriate contributors tagged
- Contributor assigned/self-assigned
Activity