The error arises from conflicting logic in the function. Initially, it checks if startTime_
is greater than or equal to endTime_
, returning 0 if true. Later, it assumes startTime_
equals endTime_
, leading to unreachable code. This contradiction results in unnecessary computation and suggests a need for logic adjustment.
According to the conditions if (startTime_ < payoutStart_) { startTime_ = payoutStart_; }
and if (startTime_ >= endTime_) { return 0; }
,it can be inferred that the range of startTime_
is that payoutStart_ <= startTime_ < endTime_
; Therefore, when evaluating if ((timePassedBefore_ / interval_) == ((endTime_ - payoutStart_) / interval_))
, it means that ((startTime_ - payoutStart_) /interval_) == ((endTime_ - payoutStart_) / interval_). In other words, startTime_ == endTime_
,which contradicts the earlier calculation if (startTime_ >= endTime_) { return 0; }
,leading to the subsequent code block never being executed. Furthermore, even if it is executed, because startTime_ == endTime_
,the result of (intervalFullReward_ * (endTime_ - startTime_)) / interval_
will also be 0, resulting in unnecessary computation.
Therefore, based on the logic, it is suggested to change the ==
to <
.
Additionally, there is a spelling error in the notification. It is suggested to change "then" to "than", as shown below:
LinearDistributionIntervalDecrease::getPeriodReward
The contradictory logic in the function results in unreachable code and unnecessary computation.
Manual Review
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.