自我毁灭的坚固性

时间:2018-05-14 00:35:04

标签: solidity web3 geth

我在geth中发现了SelfDestruct问题 我没有在智能合约上调用SelfDestruct 但是,重新启动我实现geth的服务器PC后,我的合同突然自行破坏了。 我对这种问题一无所知。 是否有任何自我毁灭的条件,我不知道?

    pragma solidity^0.4.19;

contract Dan_v1_1 {
    struct DanInfo {
        string file_path;
        string kor_name;
        string personal_key;
        string eng_name;
        uint8 gradeOfpoomDan;
        string danCertificate;
        uint[] regDateHistory;
        bool flag;
    }

    mapping (string => DanInfo) danInfo;
    mapping (uint => string) indexOfDanInfo;
    uint private danInfoCount = 0;

    address contractOwner;

    function Dan_v1_1() public{
        contractOwner = msg.sender;
    }

    function setInitDanInfo (string file_path,string kor_name, string personal_key,string eng_name,
        uint8 gradeOfpoomDan,string danCertificate, uint []regDateHistory, bool flag) 
        public{
        require (keccak256(danInfo[personal_key].personal_key) != keccak256(personal_key));
        danInfo[personal_key] = DanInfo(file_path,kor_name, personal_key,eng_name,gradeOfpoomDan,danCertificate,regDateHistory,flag);
        indexOfDanInfo[danInfoCount++] = personal_key;
    }

    function getDanInfoCount () public constant returns(uint) {
        return danInfoCount;
    }

    function getDanInfo (string personal_key) public constant returns(string,string, string, string, uint8, string, uint[], bool) {
        DanInfo memory temp = danInfo[personal_key];
        return(temp.file_path,temp.kor_name, temp.personal_key, temp.eng_name, temp.gradeOfpoomDan, temp.danCertificate, temp.regDateHistory, temp.flag);
    }

    function killContract() public{
        if(contractOwner == msg.sender) {
            selfdestruct(contractOwner);
        }
    }
}

0 个答案:

没有答案