Changed naming for example contract variables to avoid static analysis warnings

pull/1/head
holgerd77 7 years ago
parent d1883d7e4b
commit 82cdfd453e
  1. 26
      src/app/editor/example-contracts.js

@ -24,11 +24,11 @@ contract Ballot {
proposals.length = _numProposals; proposals.length = _numProposals;
} }
/// Give $(voter) the right to vote on this ballot. /// Give $(toVoter) the right to vote on this ballot.
/// May only be called by $(chairperson). /// May only be called by $(chairperson).
function giveRightToVote(address voter) public { function giveRightToVote(address toVoter) public {
if (msg.sender != chairperson || voters[voter].voted) return; if (msg.sender != chairperson || voters[toVoter].voted) return;
voters[voter].weight = 1; voters[toVoter].weight = 1;
} }
/// Delegate your vote to the voter $(to). /// Delegate your vote to the voter $(to).
@ -47,21 +47,21 @@ contract Ballot {
delegateTo.weight += sender.weight; delegateTo.weight += sender.weight;
} }
/// Give a single vote to proposal $(proposal). /// Give a single vote to proposal $(toProposal).
function vote(uint8 proposal) public { function vote(uint8 toProposal) public {
Voter storage sender = voters[msg.sender]; Voter storage sender = voters[msg.sender];
if (sender.voted || proposal >= proposals.length) return; if (sender.voted || toProposal >= proposals.length) return;
sender.voted = true; sender.voted = true;
sender.vote = proposal; sender.vote = toProposal;
proposals[proposal].voteCount += sender.weight; proposals[toProposal].voteCount += sender.weight;
} }
function winningProposal() public constant returns (uint8 _winningProposal) { function winningProposal() public constant returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0; uint256 winningVoteCount = 0;
for (uint8 proposal = 0; proposal < proposals.length; proposal++) for (uint8 prop = 0; prop < proposals.length; prop++)
if (proposals[proposal].voteCount > winningVoteCount) { if (proposals[prop].voteCount > winningVoteCount) {
winningVoteCount = proposals[proposal].voteCount; winningVoteCount = proposals[prop].voteCount;
_winningProposal = proposal; _winningProposal = prop;
} }
} }
}` }`

Loading…
Cancel
Save