0x00000002 / rootcore

Apache License 2.0
0 stars 1 forks source link

state mutibility can be restricted to pure #15

Open gabriel-canaan opened 6 years ago

gabriel-canaan commented 6 years ago

rootcore/blob/master/contracts/Utils.sol Line 55,68

 function safeSub(uint256 _x, uint256 _y) internal returns (uint256) {
        assert(_x >= _y);
        return _x - _y;
    }
  function safeMul(uint256 _x, uint256 _y) internal returns (uint256) {
        uint256 z = _x * _y;
        assert(_x == 0 || z / _x == _y);
        return z;
    }
gabriel-canaan commented 6 years ago

If is possible to make a function pure, as in this case it is advisable to do so.To prevent you from accidentally reading or writing contract state and call it for example through web3.js without needing a transaction, without any gas cost and without confirmation delay.