Skip to content
Snippets Groups Projects
Commit 2c6119e1 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Minor tweaks

parent a84e4f89
No related branches found
No related tags found
No related merge requests found
...@@ -20,8 +20,8 @@ contract Ballot { ...@@ -20,8 +20,8 @@ contract Ballot {
struct Votingrules { struct Votingrules {
string title; string title;
address chairman; address chairman;
uint voteAtOrAfter; uint voteStarts;
uint voteAtOrBefore; uint voteBefore;
// A NOTE ON PERCENTAGES // A NOTE ON PERCENTAGES
// At present floats do not exist. Since we merely use // At present floats do not exist. Since we merely use
// our floats to later present to the outside world, // our floats to later present to the outside world,
...@@ -60,8 +60,8 @@ contract Ballot { ...@@ -60,8 +60,8 @@ contract Ballot {
/// Create a new ballot to choose one of `proposalNames`. /// Create a new ballot to choose one of `proposalNames`.
constructor( constructor(
string ballotTitle, string ballotTitle,
uint voteAtOrAfter, uint voteStarts,
uint voteAtOrBefore, uint voteBefore,
uint percentOfRegisteredVotersReqToBeValid, uint percentOfRegisteredVotersReqToBeValid,
uint percentOfVotesCastToWin, uint percentOfVotesCastToWin,
bool countNonvotesAsBlanks, bool countNonvotesAsBlanks,
...@@ -69,13 +69,15 @@ contract Ballot { ...@@ -69,13 +69,15 @@ contract Ballot {
) )
public public
{ {
require( voteAtOrBefore > now ); require( voteBefore > now );
require( percentOfRegisteredVotersReqToBeValid <= 100000000 );
require( percentOfVotesCastToWin <= 100000000 );
// chairman can not automatically vote. Chairman must // chairman can not automatically vote. Chairman must
// giveRightToVote to himself if he wants to vote. // giveRightToVote to himself if he wants to vote.
rules.chairman = msg.sender; rules.chairman = msg.sender;
rules.title = ballotTitle; rules.title = ballotTitle;
rules.voteAtOrAfter = voteAtOrAfter; rules.voteStarts = voteStarts;
rules.voteAtOrBefore = voteAtOrBefore; rules.voteBefore = voteBefore;
rules.percentOfRegisteredVotersReqToBeValid = percentOfRegisteredVotersReqToBeValid; rules.percentOfRegisteredVotersReqToBeValid = percentOfRegisteredVotersReqToBeValid;
rules.percentOfVotesCastToWin = percentOfVotesCastToWin; rules.percentOfVotesCastToWin = percentOfVotesCastToWin;
rules.countNonvotesAsBlanks = countNonvotesAsBlanks; rules.countNonvotesAsBlanks = countNonvotesAsBlanks;
...@@ -104,8 +106,8 @@ contract Ballot { ...@@ -104,8 +106,8 @@ contract Ballot {
public public
{ {
// May only be called by chairman. // May only be called by chairman.
require( msg.sender == rules.chairman ); require( msg.sender == rules.chairman );
require( rules.voteAtOrBefore <= now ); require( rules.voteBefore < now );
uint idx = voterMap[voter]; uint idx = voterMap[voter];
// Can't add voters more than once. // Can't add voters more than once.
require( idx == 0 ); require( idx == 0 );
...@@ -145,8 +147,8 @@ contract Ballot { ...@@ -145,8 +147,8 @@ contract Ballot {
public public
{ {
require( proposal < numproposals ); require( proposal < numproposals );
require( rules.voteAtOrAfter >= now ); require( rules.voteStarts >= now );
require( rules.voteAtOrBefore <= now ); require( rules.voteBefore < now );
int idx = getVoterIdx( msg.sender ); int idx = getVoterIdx( msg.sender );
require( idx > -1 ); require( idx > -1 );
uint uidx = uint( idx ); uint uidx = uint( idx );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment