diff --git a/src/Ballot.sol b/src/Ballot.sol index 72fcd4840a410a5b7dd5d8b8ac1124c206ec5aac..a451841f6f40dddcf13d4b056f46a22d45170103 100644 --- a/src/Ballot.sol +++ b/src/Ballot.sol @@ -20,8 +20,8 @@ contract Ballot { struct Votingrules { string title; address chairman; - uint voteAtOrAfter; - uint voteAtOrBefore; + uint voteStarts; + uint voteBefore; // A NOTE ON PERCENTAGES // At present floats do not exist. Since we merely use // our floats to later present to the outside world, @@ -60,8 +60,8 @@ contract Ballot { /// Create a new ballot to choose one of `proposalNames`. constructor( string ballotTitle, - uint voteAtOrAfter, - uint voteAtOrBefore, + uint voteStarts, + uint voteBefore, uint percentOfRegisteredVotersReqToBeValid, uint percentOfVotesCastToWin, bool countNonvotesAsBlanks, @@ -69,13 +69,15 @@ contract Ballot { ) public { - require( voteAtOrBefore > now ); + require( voteBefore > now ); + require( percentOfRegisteredVotersReqToBeValid <= 100000000 ); + require( percentOfVotesCastToWin <= 100000000 ); // chairman can not automatically vote. Chairman must // giveRightToVote to himself if he wants to vote. rules.chairman = msg.sender; rules.title = ballotTitle; - rules.voteAtOrAfter = voteAtOrAfter; - rules.voteAtOrBefore = voteAtOrBefore; + rules.voteStarts = voteStarts; + rules.voteBefore = voteBefore; rules.percentOfRegisteredVotersReqToBeValid = percentOfRegisteredVotersReqToBeValid; rules.percentOfVotesCastToWin = percentOfVotesCastToWin; rules.countNonvotesAsBlanks = countNonvotesAsBlanks; @@ -104,8 +106,8 @@ contract Ballot { public { // May only be called by chairman. - require( msg.sender == rules.chairman ); - require( rules.voteAtOrBefore <= now ); + require( msg.sender == rules.chairman ); + require( rules.voteBefore < now ); uint idx = voterMap[voter]; // Can't add voters more than once. require( idx == 0 ); @@ -145,8 +147,8 @@ contract Ballot { public { require( proposal < numproposals ); - require( rules.voteAtOrAfter >= now ); - require( rules.voteAtOrBefore <= now ); + require( rules.voteStarts >= now ); + require( rules.voteBefore < now ); int idx = getVoterIdx( msg.sender ); require( idx > -1 ); uint uidx = uint( idx );