Skip to content

Commit

Permalink
feat: impl vote
Browse files Browse the repository at this point in the history
  • Loading branch information
bguiz committed Oct 5, 2020
1 parent 61345bc commit 0b031b7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions contracts/Election.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ contract Election {
function vote (
uint _candidateId
) public {
// TODO check that account hasn't voted before
// and that candidate is valid
// require that they haven't voted before
require(
!voters[msg.sender]);

// require a valid candidate
require(
_candidateId > 0 &&
_candidateId <= candidatesCount);

// TODO record that voter has voted
// record that voter has voted
voters[msg.sender] = true;

// update candidate vote Count
candidates[_candidateId].voteCount++;
}
}

0 comments on commit 0b031b7

Please sign in to comment.