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 {
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 );
......
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