Skip to content

Instantly share code, notes, and snippets.

@Shashank-In
Created September 5, 2022 04:40
Show Gist options
  • Save Shashank-In/58d146d81055e2f4cdb155bc58e7475a to your computer and use it in GitHub Desktop.
Save Shashank-In/58d146d81055e2f4cdb155bc58e7475a to your computer and use it in GitHub Desktop.
function SendCash(uint roundIndex, uint subpotIndex){
var subpotsCount = getSubpotsCount(roundIndex);
if(subpotIndex>=subpotsCount) {
return;
}
var decisionBlocksNumber = getDecisionBlocksNumber(roundIndex,subpotIndex);
if(decisionBlocksNumber>block.number) {
return;
}
if(rounds[roundIndex].isCashed[subpotIndex]) {
return;
}
// Prevent double payouts
var winner = calculateWinnerEarning(roundIndex,subpotIndex);
var subpot = getSubpot(roundIndex);
winner.send(subpot);
rounds[roundIndex].isCashed[subpotIndex] = true;
//Mark all the round as cashed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment