From 2c6119e1320cf91fb293d93f54f755043fbf7253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Martin-Leg=C3=A8ne?= <robert@nic.ar> Date: Wed, 31 Oct 2018 12:34:13 -0300 Subject: [PATCH] Minor tweaks --- src/Ballot.sol | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Ballot.sol b/src/Ballot.sol index 72fcd48..a451841 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 ); -- GitLab