use short circuit (#654)

This commit is contained in:
JU HYEONG PARK
2018-01-20 03:45:48 +09:00
committed by Francisco Giordano
parent 6979e3c83a
commit 9cc55ef2a5

View File

@ -22,14 +22,14 @@ contract CappedCrowdsale is Crowdsale {
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
bool capReached = weiRaised >= cap;
return super.hasEnded() || capReached;
return capReached || super.hasEnded();
}
// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal view returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
return withinCap && super.validPurchase();
}
}