Created
November 12, 2017 20:17
-
-
Save skmgoldin/e130f3b18162f58b5a17cf617c308b9f 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 resolveChallenge(string _domain) private { | |
bytes32 domainHash = keccak256(_domain); | |
Listing storage listing = listings[domainHash]; | |
Challenge.Data storage challenge = challenges[listing.challengeID]; | |
// Calculates the winner's reward, | |
// which is: (winner's full stake) + (dispensationPct * loser's stake) | |
uint winnerReward = challenge.challengeWinnerReward(); | |
// Records whether the domain is a listing or an application | |
bool wasWhitelisted = isWhitelisted(_domain); | |
// Case: challenge failed | |
if (voting.isPassed(challenge.challengeID)) { | |
whitelistApplication(_domain); | |
// Unlock stake so that it can be retrieved by the applicant | |
listing.unstakedDeposit += winnerReward; | |
_ChallengeFailed(challenge.challengeID); | |
if (!wasWhitelisted) { _NewDomainWhitelisted(_domain); } | |
} | |
// Case: challenge succeeded | |
else { | |
resetListing(_domain); | |
// Transfer the reward to the challenger | |
require(token.transfer(challenge.challenger, winnerReward)); | |
_ChallengeSucceeded(challenge.challengeID); | |
if (wasWhitelisted) { _ListingRemoved(_domain); } | |
else { _ApplicationRemoved(_domain); } | |
} | |
challenge.winningTokens = | |
challenge.voting.getTotalNumberOfTokensForWinningOption(challenge.challengeID); | |
challenge.resolved = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment