Created
November 12, 2017 20:34
-
-
Save skmgoldin/03f187f0b2608f8092594d38bd304de5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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