Pausable.sol 732 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. pragma solidity ^0.4.8;
  2. import "../ownership/Ownable.sol";
  3. /*
  4. * Pausable
  5. * Abstract contract that allows children to implement a
  6. * pause mechanism.
  7. */
  8. contract Pausable is Ownable {
  9. event Pause();
  10. event Unpause();
  11. bool public paused = false;
  12. modifier whenNotPaused() {
  13. if (paused) throw;
  14. _;
  15. }
  16. modifier whenPaused {
  17. if (!paused) throw;
  18. _;
  19. }
  20. // called by the owner to pause, triggers stopped state
  21. function pause() onlyOwner whenNotPaused returns (bool) {
  22. paused = true;
  23. Pause();
  24. return true;
  25. }
  26. // called by the owner to unpause, returns to normal state
  27. function unpause() onlyOwner whenPaused returns (bool) {
  28. paused = false;
  29. Unpause();
  30. return true;
  31. }
  32. }