Pausable.sol 676 B

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