Skip to content

Instantly share code, notes, and snippets.

@skmgoldin
Created November 12, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skmgoldin/03f187f0b2608f8092594d38bd304de5 to your computer and use it in GitHub Desktop.
Save skmgoldin/03f187f0b2608f8092594d38bd304de5 to your computer and use it in GitHub Desktop.
function claimReward(Data storage _self, address _voter, uint _salt) public returns (uint) {
// Ensures the voter has not already claimed tokens and challenge results have been processed
require(_self.tokenClaims[_voter] == false);
require(isResolved(_self));
uint voterTokens = _self.voting.getNumPassingTokens(_voter, _self.challengeID, _salt);
uint reward = voterReward(_self, _voter, _salt);
// Subtracts the voter's information to preserve the participation ratios
// of other voters compared to the remaining pool of rewards
_self.winningTokens -= voterTokens;
_self.rewardPool -= reward;
require(_self.token.transfer(_voter, reward));
// Ensures a voter cannot claim tokens again
_self.tokenClaims[_voter] = true;
return reward;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment