mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
52 lines
951 B
Solidity
52 lines
951 B
Solidity
pragma solidity ^0.4.11;
|
|
|
|
|
|
import "../ownership/Ownable.sol";
|
|
|
|
|
|
/**
|
|
* @title Pausable
|
|
* @dev Base contract which allows children to implement an emergency stop mechanism.
|
|
*/
|
|
contract Pausable is Ownable {
|
|
event Pause();
|
|
event Unpause();
|
|
|
|
bool public paused = false;
|
|
|
|
|
|
/**
|
|
* @dev modifier to allow actions only when the contract IS paused
|
|
*/
|
|
modifier whenNotPaused() {
|
|
if (paused) throw;
|
|
_;
|
|
}
|
|
|
|
/**
|
|
* @dev modifier to allow actions only when the contract IS NOT paused
|
|
*/
|
|
modifier whenPaused {
|
|
if (!paused) throw;
|
|
_;
|
|
}
|
|
|
|
/**
|
|
* @dev called by the owner to pause, triggers stopped state
|
|
*/
|
|
function pause() onlyOwner whenNotPaused returns (bool) {
|
|
paused = true;
|
|
Pause();
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @dev called by the owner to unpause, returns to normal state
|
|
*/
|
|
function unpause() onlyOwner whenPaused returns (bool) {
|
|
paused = false;
|
|
Unpause();
|
|
return true;
|
|
}
|
|
}
|