aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-27 07:17:46 +0800
committerGitHub <noreply@github.com>2018-02-27 07:17:46 +0800
commit1f5eb4ba59891387c2dfcc10103c2f187bf2b4ee (patch)
tree6e47f8ed2c222d68bcc62941339ec16ad87106c8
parent3aaa5c4a35952b3b1a50aeeee8a8b68521e7fe3b (diff)
parent098033c94a6bbedaee60b19f096dfee5bf2b4550 (diff)
downloaddexon-solidity-1f5eb4ba59891387c2dfcc10103c2f187bf2b4ee.tar.gz
dexon-solidity-1f5eb4ba59891387c2dfcc10103c2f187bf2b4ee.tar.zst
dexon-solidity-1f5eb4ba59891387c2dfcc10103c2f187bf2b4ee.zip
Merge pull request #3335 from nisdas/ballot-contract
Fixes the errors in the sample ballot contract
-rw-r--r--docs/solidity-by-example.rst23
1 files changed, 14 insertions, 9 deletions
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst
index e5b44c98..57556fa5 100644
--- a/docs/solidity-by-example.rst
+++ b/docs/solidity-by-example.rst
@@ -94,7 +94,11 @@ 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 && (voters[voter].weight == 0));
+ require(
+ (msg.sender == chairperson) &&
+ !voters[voter].voted &&
+ (voters[voter].weight == 0)
+ );
voters[voter].weight = 1;
}
@@ -126,15 +130,15 @@ of votes.
// modifies `voters[msg.sender].voted`
sender.voted = true;
sender.delegate = to;
- Voter storage delegate = voters[to];
- if (delegate.voted) {
+ Voter storage delegate_ = voters[to];
+ if (delegate_.voted) {
// If the delegate already voted,
// directly add to the number of votes
- proposals[delegate.vote].voteCount += sender.weight;
+ proposals[delegate_.vote].voteCount += sender.weight;
} else {
// If the delegate did not vote yet,
// add to her weight.
- delegate.weight += sender.weight;
+ delegate_.weight += sender.weight;
}
}
@@ -155,13 +159,13 @@ of votes.
/// @dev Computes the winning proposal taking all
/// previous votes into account.
function winningProposal() public view
- returns (uint winningProposal)
+ returns (uint winningProposal_)
{
uint winningVoteCount = 0;
for (uint p = 0; p < proposals.length; p++) {
if (proposals[p].voteCount > winningVoteCount) {
winningVoteCount = proposals[p].voteCount;
- winningProposal = p;
+ winningProposal_ = p;
}
}
}
@@ -170,12 +174,13 @@ of votes.
// of the winner contained in the proposals array and then
// returns the name of the winner
function winnerName() public view
- returns (bytes32 winnerName)
+ returns (bytes32 winnerName_)
{
- winnerName = proposals[winningProposal()].name;
+ winnerName_ = proposals[winningProposal()].name;
}
}
+
Possible Improvements
=====================