Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing governance iterators #4439

Closed
4 tasks
fedekunze opened this issue May 29, 2019 · 3 comments · Fixed by #4460
Closed
4 tasks

Missing governance iterators #4439

fedekunze opened this issue May 29, 2019 · 3 comments · Fixed by #4460
Assignees
Labels
C:x/gov Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.

Comments

@fedekunze
Copy link
Collaborator

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
@fedekunze fedekunze added C:x/gov refactor Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity. labels May 29, 2019
@jackzampolin
Copy link
Member

This seems like a quick one. Maybe also tackle this issue: #3386

@fedekunze
Copy link
Collaborator Author

This seems like a quick one.

👍 I think this is blocked by #4437 tho...

@alexanderbez
Copy link
Contributor

Thanks @fedekunze

@fedekunze fedekunze self-assigned this May 31, 2019
This was referenced May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/gov Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants