The Staking::update()
will be invoked every time the following functions are executed.
Staking::update()
-- the function itself
Staking::updateFor()
Staking::deposit()
Staking::withdraw()
Staking::claim()
The "if (_diff > 0) { ... }
" condition check in the update()
is unnecessary since the _diff
variable will always be more than 0 due to the outer "if (_balance > balance) { ... }
" condition check.
https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Staking.sol#L67
I recommend removing the "if (_diff > 0) { ... }
" condition check for gas savings, as shown below.
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.