aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDillon Arevalo <dillonbarevalo@gmail.com>2017-06-21 11:48:49 +0800
committerDillon Arevalo <dillonbarevalo@gmail.com>2017-06-21 11:48:49 +0800
commit552f2e5303f89b78491a6f267ce54badbdfc8f2e (patch)
tree1d05d78f3246580cc53b037d67ce032cc81e0dae
parentcb5f2f90f6d70f299bd0a4e0e6ed597fd728180b (diff)
downloaddexon-solidity-552f2e5303f89b78491a6f267ce54badbdfc8f2e.tar.gz
dexon-solidity-552f2e5303f89b78491a6f267ce54badbdfc8f2e.tar.zst
dexon-solidity-552f2e5303f89b78491a6f267ce54badbdfc8f2e.zip
Add weight == 0 condition to giveRightToVote function
This will make it so votes can't be deleted accidentally by giving someone with weight > 1 the right to vote again
-rw-r--r--docs/solidity-by-example.rst8
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst
index 993e2c18..450b0286 100644
--- a/docs/solidity-by-example.rst
+++ b/docs/solidity-by-example.rst
@@ -94,7 +94,7 @@ of votes.
// called incorrectly. But watch out, this
// will currently also consume all provided gas
// (this is planned to change in the future).
- require((msg.sender == chairperson) && !voters[voter].voted);
+ require((msg.sender == chairperson) && !voters[voter].voted && (voters[voter].weight == 0));
voters[voter].weight = 1;
}
@@ -165,7 +165,7 @@ of votes.
}
}
}
-
+
// Calls winningProposal() function to get the index
// of the winner contained in the proposals array and then
// returns the name of the winner
@@ -273,7 +273,7 @@ activate themselves.
// If the bid is not higher, send the
// money back.
require(msg.value > highestBid);
-
+
if (highestBidder != 0) {
// Sending back the money by simply using
// highestBidder.send(highestBid) is a security risk
@@ -296,7 +296,7 @@ activate themselves.
// before `send` returns.
pendingReturns[msg.sender] = 0;
- if (!msg.sender.send(amount)) {
+ if (!msg.sender.send(amount)) {
// No need to call throw here, just reset the amount owing
pendingReturns[msg.sender] = amount;
return false;