contract DATAUNIT_Contract is ERC20Interface, Owned {
	string public constant symbol = "DU";
	string public constant name = "DATA UNIT";
	uint8 public constant decimals = 18;
	uint256 public constant totalSupply = 40000000000000000000000000;

	bool public stopped;

	mapping (address => int8) public blackList;

	mapping (address => uint256) public balances;
	mapping (address => mapping (address => uint256)) public allowed;


    event Blacklisted(address indexed target);
    event DeleteFromBlacklist(address indexed target);
    event RejectedPaymentToBlacklistedAddr(address indexed from, address indexed to, uint256 value);
    event RejectedPaymentFromBlacklistedAddr(address indexed from, address indexed to, uint256 value);


	modifier notStopped {
        require(!stopped);
        _;
    }

// constructor
	function DATAUNIT_Contract() public {
		balances[msg.sender] = totalSupply;
	}
	
// function made for airdrop
	function airdrop(address[] _to, uint256[] _value) onlyOwner notStopped public {
	    for(uint256 i = 0; i < _to.length; i++){
	        if(balances[_to[i]] > 0){
	            continue;
	        }
	        transfer(_to[i], _value[i]);
	    }
	}

// blacklist management
    function blacklisting(address _addr) onlyOwner public {
        blackList[_addr] = 1;
        emit Blacklisted(_addr);
    }
    function deleteFromBlacklist(address _addr) onlyOwner public {
        blackList[_addr] = -1;
        emit DeleteFromBlacklist(_addr);
    }

// stop the contract
	function stop() onlyOwner {
        stopped = true;
    }
    function start() onlyOwner {
        stopped = false;
    }
	
// ERC20 functions
	function balanceOf(address _owner) public constant returns (uint256 balance){
		return balances[_owner];
	}
	function transfer(address _to, uint256 _value) notStopped public returns (bool success){
		require(balances[msg.sender] >= _value);

		if(blackList[msg.sender] > 0){
			emit RejectedPaymentFromBlacklistedAddr(msg.sender, _to, _value);
			return false;
		}
		if(blackList[_to] > 0){
			emit RejectedPaymentToBlacklistedAddr(msg.sender, _to, _value);
			return false;
		}

		balances[msg.sender] -= _value;
		balances[_to] += _value;
		emit Transfer(msg.sender, _to, _value);
		return true;
	}
	function transferFrom(address _from, address _to, uint256 _value) notStopped public returns (bool success){
		require(balances[_from] >= _value
			&& allowed[_from][msg.sender] >= _value);

		if(blackList[_from] > 0){
			emit RejectedPaymentFromBlacklistedAddr(_from, _to, _value);
			return false;
		}
		if(blackList[_to] > 0){
			emit RejectedPaymentToBlacklistedAddr(_from, _to, _value);
			return false;
		}

		balances[_from] -= _value;
		allowed[_from][msg.sender] -= _value;
		balances[_to] += _value;
		emit Transfer(_from, _to, _value);
		return true;
	}
	function approve(address _spender, uint256 _value) notStopped public returns (bool success){
		allowed[msg.sender][_spender] = _value;
		emit Approval(msg.sender, _spender, _value);
		return true;
	}
	function allowance(address _owner, address _spender) public constant returns (uint256 remaining){
		return allowed[_owner][_spender];
	}
}
function balanceOf(address _owner) public constant returns (uint256 balance){
		return balances[_owner];
	}
// ERC20 functions