Skip to content

Gov Keys and Iterators#4460

Merged
jackzampolin merged 13 commits intomasterfrom
fedekunze/gov-fixes
Jun 4, 2019
Merged

Gov Keys and Iterators#4460
jackzampolin merged 13 commits intomasterfrom
fedekunze/gov-fixes

Conversation

@fedekunze
Copy link
Copy Markdown
Contributor

closes #4439
closes #4437

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry: clog add [section] [stanza] [message]

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@fedekunze fedekunze added the WIP label May 31, 2019
@alexanderbez alexanderbez added T: State Machine Breaking State machine breaking changes (impacts consensus). C:x/gov labels May 31, 2019
@fedekunze fedekunze marked this pull request as ready for review May 31, 2019 16:15
@fedekunze fedekunze requested review from cwgoes, mossid, sabau and sunnya97 May 31, 2019 16:16
Copy link
Copy Markdown
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fedekunze. I think this PR is a great start! I left some general feedback as I believe some of the API changes are unwarranted. In addition, I don't believe we should be passing iterators to iterator methods -- they should create the iterator internally.

Apart from this, it seems logic has been moved into context-aware files which is nice! So thanks for that ⚡️

fedekunze and others added 2 commits June 3, 2019 09:48
Co-Authored-By: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 3, 2019

Codecov Report

Merging #4460 into master will increase coverage by 0.14%.
The diff coverage is 75.69%.

@@            Coverage Diff             @@
##           master    #4460      +/-   ##
==========================================
+ Coverage   54.56%   54.71%   +0.14%     
==========================================
  Files         250      253       +3     
  Lines       16081    16112      +31     
==========================================
+ Hits         8775     8815      +40     
+ Misses       6658     6651       -7     
+ Partials      648      646       -2

@fedekunze fedekunze requested a review from alexanderbez June 3, 2019 08:24
Copy link
Copy Markdown
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more minor nitpicks, but otherwise LGTM

fedekunze and others added 2 commits June 3, 2019 16:44
Co-Authored-By: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
@fedekunze fedekunze requested a review from alexanderbez June 3, 2019 15:17
store := ctx.KVStore(keeper.storeKey)
return store.Iterator(PrefixInactiveProposalQueue, sdk.PrefixEndBytes(PrefixInactiveProposalQueueTime(endTime)))
// IterateVotes iterates over the all the proposals votes and performs a callback function
func (keeper Keeper) IterateVotes(ctx sdk.Context, proposalID uint64, cb func(vote types.Vote) (stop bool)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change cb name with something that simplify the understanding of his purpose and or describe it in the comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cb is the callback function that's described on the comment

Copy link
Copy Markdown
Contributor

@sabau sabau Jun 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, I would give to this callback function a name that reminds us what's his purpose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the name cb is pretty universal. It's used in Javascript/Node.js too

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think cb or handler suffices here 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not calling all of them done it's another universal one but helps a bit more.
It's not only related to this PR, everywhere we are using fn, handle or cb for this case, and in all cases what the function does is stop the for loop (plus his callbacky stuff)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not calling all of them done it's another universal one but helps a bit more.
It's not only related to this PR, everywhere we are using fn, handle or cb for this case, and in all cases what the function does is stop the for loop (plus his callbacky stuff)

I think that question should be addressed as part of #3386

Copy link
Copy Markdown
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK pending simulation passing 👍

Copy link
Copy Markdown
Contributor

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great code clean up. Looking good @fedekunze 😎

@sabau sabau mentioned this pull request Jun 4, 2019
@jackzampolin jackzampolin merged commit fe695b8 into master Jun 4, 2019
@jackzampolin jackzampolin deleted the fedekunze/gov-fixes branch June 4, 2019 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C:x/gov T: State Machine Breaking State machine breaking changes (impacts consensus).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing governance iterators Gov module should use byte prefixes instead of strings for keys

4 participants