pragma solidity ^0.4.24;


contract DecentralizedPausableMock {
    uint public counter;
    mapping(uint => mapping(address => bool)) public unpaused;
    uint public blockStartNumber;
    bool public paused;

  /**
   * @dev Modifier to make a function callable only when the contract is not paused.
   */
  modifier whenNotPaused() {
    if(paused) {
      require(unpaused[blockStartNumber][msg.sender]);
    }
    _;
  }

  /**
   * @dev Modifier to make a function callable only when the contract is paused.
   */
  modifier whenPaused() {
    if(paused) {
      require(!unpaused[blockStartNumber][msg.sender]);
    } else {
        revert();
    }
    _;
  }

    function countup() public whenNotPaused {
        counter++;
    }

    function unpauseOnlySelf() public whenPaused {
        unpaused[blockStartNumber][msg.sender] = true;
    }

    function pause() public whenNotPaused {
        paused = true;
        blockStartNumber = block.number;
    }

    function unpause() public {
        paused = false;
    }
}