You are viewing a single comment's thread from:

RE: Whitelist Process

in #quarkchain6 years ago

for those avid of details, thank Michael Srb for this Here's how QuarkChain's lottery worked:
line 74: total_score = sum(c.score for c in candidates) — sum of all scores of all not-yet-whitelisted candidates
line 75: chosen = random.random() * total_score — pick random number between 0 - total_score
line 76: for i, c in enumerate(candidates): — let's iterate over sorted list of all candidates
line 77: if chosen <= c.score: — check if chosen number is <= than the score of the currently selected candidate (this is important as if the first candidate had 100 then he/she would be whitelisted if chosen number is <= 100; but if the first candidate had only 60 points then the chosen number would need to be <= 60 —- and this is why people with higher score had greater chance to win)
line 78: whitelist.append(c) — whitelist candidate if the condition on line 77 was true
line 79: candidates.pop(i) — remove the candidate from the sorted list so he/she will not be whitelisted twice
line 80: break — we've already whitelisted one candidate this round so let's start over and jump to line 74
line 81: chosen -= c.score — this line gets executed if the condition on line 77 is false, i.e. chosen number is not <= than score of the currently selected candidate; so we will subtract candidate's score from the chosen number and we will jump to line 76 where we select another candidate and repeat the process from there

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.029
BTC 61039.43
ETH 2460.28
USDT 1.00
SBD 2.66