DefconPro - Alternative to Pausable.sol

I wanted a multilevel pause for my project so I modeled a contract after the DEFCON system that the US military uses. Add the defcon4 modifier to high risk functions, and defcon1 modifier for low risk functions. Raise the defcon level from 5-1 depending on the severity of the situation.


pragma solidity 0.4.18;
import 'browser/Ownable.sol';

/*DefconPro is built to mimic DEFCON or Defense Readiness Condition, which is an alert state used by the US military.
it is meant to be used as an alternative to the old Pausable contract. Instead of one pause level, DefconPro has 4.
Use the defcon1 modifier for low risk functions and defcon4 for high risk functions.
Raise the defcon level to pause functions based on risk levels.*/

contract DefconPro is Ownable {
event Defcon(uint64 blockNumber, uint16 defconLevel);

uint16 public defcon = 5;//default defcon level of 5 means everything is cool, no problems

//if defcon is set to 4 or lower then function is paused
modifier defcon4() {//use this for high risk functions
require(defcon > 4);
_;
}

//if defcon is set to 3 or lower then function is paused
modifier defcon3() {
require(defcon > 3);
_;
}

//if defcon is set to 2 or lower then function is paused
modifier defcon2() {
require(defcon > 2);
_;
}

//if defcon is set to 1 or lower then function is paused
modifier defcon1() {//use this for low risk functions
require(defcon > 1);
_;
}

//set the defcon level, 5 is unpaused, 1 is EVERYTHING is paused
function setDefconLevel(uint16 _defcon) onlyOwner public {
defcon = _defcon;
Defcon(uint64(block.number), _defcon);
}

}
Sign In or Register to comment.