contract Controllers {
    event LogController(address indexed addr, bool indexed isChief);

    // StakeAllIndex Address.
    address public immutable stakeAllIndex;

    constructor(address _stakeAllIndex) {
        stakeAllIndex = _stakeAllIndex;
    }

    // Enabled Chief(Address of Chief => bool).
    mapping(address => bool) public chief;
    // Enabled Connectors(Connector name => address).
    mapping(string => address) public connectors;

    /**
     * @dev Throws if the sender not is Master Address from StakeAllIndex
     * or Enabled Chief.
     */
    modifier isChief() {
        require(
            chief[msg.sender] ||
                msg.sender == IndexInterface(stakeAllIndex).master(),
            "not-an-chief"
        );
        _;
    }

    /**
     * @dev Toggle a Chief. Enable if disable & vice versa
     * @param _chiefAddress Chief Address.
     */
    function toggleChief(address _chiefAddress) external {
        require(
            msg.sender == IndexInterface(stakeAllIndex).master(),
            "toggleChief: not-master"
        );
        chief[_chiefAddress] = !chief[_chiefAddress];
        emit LogController(_chiefAddress, chief[_chiefAddress]);
    }
}
function toggleChief(address _chiefAddress) external {
    require(
        msg.sender == IndexInterface(stakeAllIndex).master(),
        "toggleChief: not-master"
    );
    chief[_chiefAddress] = !chief[_chiefAddress];
    emit LogController(_chiefAddress, chief[_chiefAddress]);
}

/**
 * @dev Toggle a Chief. Enable if disable & vice versa
 * @param _chiefAddress Chief Address.
 */