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

multi: Rename vote choice IsIgnore to IsAbstain. #656

Merged
merged 1 commit into from
Apr 24, 2017

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Apr 10, 2017

This renames the chaincfg parameter for the vote choice which represents an abstaining vote to be named IsAbstain instead of IsIgnore since that more accurately describes its intent and behavior.

It also updates the RPC server choice result field for isignore to be named isabstain to match.

Finally, it renames other internal variables which make use of the choice to include the word abstain as well for clarity.

Closes #655.

Copy link
Member

@jrick jrick left a comment

Choose a reason for hiding this comment

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

Other than these questions, I think this is also a breaking change to the json-rpc server and should likely require a major version bump there.

chaincfg/init.go Outdated
@@ -60,7 +60,7 @@ func shift(mask uint16) uint {

func validateChoices(mask uint16, choices []Choice) error {
var (
isIgnore, isNo int
isAbstain, isNo int
Copy link
Member

Choose a reason for hiding this comment

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

unrelated, but why are these ints?

Copy link
Member Author

@davecgh davecgh Apr 10, 2017

Choose a reason for hiding this comment

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

They're counts (obviously poorly named ones). I just went through and did a find/replace.

EDIT: I can update them to better names though since this PR is already doing that.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good, thought they were bools.

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed to numAbstain and numNo to better reflect the fact they're counts.

@@ -121,21 +121,21 @@ var (
Id: "Abstain",
Description: "Abstain voting for Pedro",
Bits: 0x0, // 0b0000
IsIgnore: false, // XXX this is the invalid bit
IsAbstain: false, // XXX this is the invalid bit
Copy link
Member

Choose a reason for hiding this comment

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

invalid bit?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a test to ensure a vote that has the vote bits set to 0, but is not properly marked as an abstaining vote causes an error.

Copy link
Member

Choose a reason for hiding this comment

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

Now i'm really confused, I can understand that some invalid bit pattern would be an error and be interpreted as abstaining, but why is bits=0 an error?

Copy link
Member Author

@davecgh davecgh Apr 11, 2017

Choose a reason for hiding this comment

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

The choice has the Bits field set to 0 however the IsAbstain flag set to false. That is an invalid combination since a choice that doesn't have any bits set must be abstain.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer IsIgnore but meh if you guys feel strong about it

Copy link
Member

Choose a reason for hiding this comment

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

oic, these are invalid choices. ok.

IsNo: false,
},
{
Id: "Yes",
Description: "Vote for Pedro",
Bits: 0x2, // 0b0010
IsIgnore: true, // XXX this is the invalid choice
IsAbstain: true, // XXX this is the invalid choice
Copy link
Member

Choose a reason for hiding this comment

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

see previous

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, the Bits field is not 0, so having the IsAbstain flag set to true is an error. @marcopeereboom can correct me if I'm wrong, but I believe the intent here is to ensure the choices are consistently defined across agendas. That is to say that having no bits set for a particular agenda is always the abstaining choice.

Copy link
Member

Choose a reason for hiding this comment

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

This reads more like setting 0x2 as the valid option to indicate abstaining. Don't know why that would ever be used.

IsNo: false,
},
{
Id: "Yes",
Description: "Vote for Pedro",
Bits: 0x2, // 0b0010
IsIgnore: true, // XXX this is the invalid choice
IsAbstain: true, // XXX this is the invalid choice
Copy link
Member

Choose a reason for hiding this comment

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

see previous

@davecgh
Copy link
Member Author

davecgh commented Apr 11, 2017

I included a major bump in the RPC server version to account for the breaking change.

Copy link
Member

@marcopeereboom marcopeereboom left a comment

Choose a reason for hiding this comment

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

Big fat meh from me on this.

This renames the chaincfg parameter for the vote choice which represents
an abstaining vote to be named IsAbstain instead of IsIgnore since that
more accurately describes its intent and behavior.

It also updates the RPC server choice result field for isignore to be
named isabstain to match and bumps the major version accordingly.

Finally, it renames other internal variables which make use of the
choice to include the word abstain as well for clarity and renames a
couple of other internal variables.
@davecgh davecgh merged commit 05d8456 into decred:master Apr 24, 2017
@davecgh davecgh deleted the isignore_to_isabstain branch April 24, 2017 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants