The line playersPredictions[player].predictionsCount = 0;
resets the predictionsCount
to 0 before it loops through all matches to recalculate it based on the current predictions and payments. If an error occurs during the loop or if the loop is interrupted, the predictionsCount
might not be correctly updated, leaving the state inconsistent. For example, if the loop starts but doesn't complete due to an unexpected error or gas limit, predictionsCount
could be left at an incorrect value.
low : The predictionsCount
might not be correctly updated, leaving the state inconsistent.
manual Review
By refactoring the function to separate the concerns of setting a prediction and updating the count, and by using more robust condition checks, the function becomes more reliable and efficient, reducing the risk of state inconsistencies.
Here’s a potential refactor of the setPrediction
function to improve state consistency and efficiency:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.