Stoppable.sol 602 B

12345678910111213141516171819202122232425262728
  1. pragma solidity ^0.4.4;
  2. import "./Ownable.sol";
  3. /*
  4. * Stoppable
  5. * Abstract contract that allows children to implement an
  6. * emergency stop mechanism.
  7. */
  8. contract Stoppable is Ownable {
  9. bool public stopped;
  10. modifier stopInEmergency { if (!stopped) _; }
  11. modifier onlyInEmergency { if (stopped) _; }
  12. // called by the owner on emergency, triggers stopped state
  13. function emergencyStop() external onlyOwner {
  14. stopped = true;
  15. }
  16. // called by the owner on end of emergency, returns to normal state
  17. function release() external onlyOwner onlyInEmergency {
  18. stopped = false;
  19. }
  20. }