I know it is a view function and it does not change the state of the contract but it can be optimized to become more gas-efficient.
The isHappyHorse() function checkes a bool with an if statement and return true
/false
accordingly instead of directly returning the boolean expression. Also, a <=
is used when it can be avoided by using a >
instead.
The code that is going to be deployed is larger, hence the gas payed by the deployer is higher than it should be. And users calling this function will be charged with higher gas fees
Manual review
Replace:
function isHappyHorse(uint256 horseId) external view returns (bool) {
if (horseIdToFedTimeStamp[horseId] <= block.timestamp - HORSE_HAPPY_IF_FED_WITHIN) {
return false;
}
return true;
}
By:
function isHappyHorse(uint256 horseId) external view returns (bool) {
return (horseIdToFedTimeStamp[horseId] > block.timestamp - HORSE_HAPPY_IF_FED_WITHIN)
}
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.