<commit_before>pragma solidity ^0.4.10;


contract Oracle {
    function getClientData(address client) constant returns (uint256, uint256);
    function payoutClient(address client) returns (bool);
    function hookInsuranceContract(address client) returns (bool);
}


contract DummyOracle {

    address creator;

    struct ClientData {
        InsuranceBase contract;
        uint256 clientCost;
        uint256 clientPayout;
        bool paidOut;
        uint256 startBlock;
        uint256 endBlock;
        bool exists;
    }

    mapping(uint64 => ClientData) clientData;
    mapping(address => uint64[]) clients;
    uint64 dataIndex;
    //mapping(address => ClientData) clients;
    function Oracle(creator) {
        creator = msg.sender;
    }

    function getClientData(address _client, uint64 _index) constant returns (uint256, uint256) {
        ClientData client = clients[_client];
        return (client.clientCost, client.clientPayout);
    }

    function newClient(bytes32 _macbookModel) returns (uint64) { //oracle determines pricing, toy pricing scheme here; I imagine this will normally be off-chain
        ClientData memory newData;
        switch (_macbookModel) {
            case "2017":
            {
            newData.clientCost = "100";
            newData.clientPayout = "2000";
                break;
            }
            case "2016":
            {
                newData.clientCost = "90";
                newData.clientPayout = "1800";
                break;
            }
            default:
            {
                throw;
            }
        }
        newClient.startBlock = block.number;
        newClient.endBlock = block.number + 1000;
        newClient.exists = true;
        let userDataIndex = dataIndex;
        clients[userDataIndex] = newData;
        clientData[msg.sender].push(userDataIndex);
        dataIndex++;
        return userDataIndex;
    }

    function hookInsuranceContract(address _client) returns (bool) {
        if (clients[_client].exists) {
            InsuranceBase contract = InsuranceBase(msg.sender);
            if (contract) {
                clients[_client].contract = contract;
            }
        }
    }

    function payoutClient(address _client) { //oracle has determined that this client's insurance claim is valid
        if (msg.sender != creator) {
            throw;
        }
        if (clients[_client].exists) {
            clients[_client].paidOut = true;
            contract.payoutClient(_client, clients[_client].clientPayout);
            return true;
        }
        return false;
    }
}

contract Syndiacte {
    address owner = msg.sender;

    struct InsuranceInstance {
        address client;
        address orcale;
        uint256 clientCost;
        uint256 clientPayout;
    }

    //what needs to happen
    mapping(address => bool) acceptedOracles;
    mapping(uint64 => InsuranceInstance) insuranceContracts;
    mapping(address => uint64[]) userContracts;
    uint64 contractInstance;

    uint256 totalBalance;
    uint256 totalDividends;
    uint256 totalPayouts;

    function addOracle(address oracleAddress) {
        Oracle oracle = Oracle.at(oracleAddress);
        if (oracle) {
            acceptedOracles[oracleAddress] = true;
        } //??
    }

    function insureClient(addresss _oracle, address _client, uint64 _oracleDataIndex) {
        
        if (!acceptedOracles[_oracle] {
            throw;
        }
        Oracle oracle = Oracle(_oracle);
        if (oracle.creator != msg.sender) {
            throw;
        }
        if (!oracle) {
            throw;
        }
        var (clientCost, clientPayout) = oracle.getClientData(_client, _oracleDataIndex);
        if (clientCost > 0 && clientPayout > 0 && clientCost < balance[_client] && clientPayout < totalBalance) {
            InsuranceInstance memory insuranceInstance;
            insuranceInstance.client = _client;
            insuranceInstance.oracle = _oracle;
            insuranceInstance.oracleDataIndex = _oracleDataIndex;
            insuranceInstance.clientCost = clientCost;
            insuranceInstance.clientPayout = clientPayout;
           //
            insuranceContracts[_client].push(insuranceInstance);
            updateBalance(_client);
            balance[_client] -= clientCost;<commit_msg>Updated solidity contract<commit_after>pragma solidity ^0.4.10;


contract Oracle {
    function getClientData(address client) constant returns (uint256, uint256);
    function payoutClient(address client) returns (bool);
    function hookInsuranceContract(address client) returns (bool);
}


contract DummyOracle {

    address creator;

    struct ClientData {
        InsuranceBase contract;
        uint256 clientCost;
        uint256 clientPayout;
        bool paidOut;
        uint256 duration;
        bool exists;
    }

    mapping(uint64 => ClientData) clientData;
    mapping(address => uint64[]) clients;
    uint64 dataIndex;
    //mapping(address => ClientData) clients;
    function DummyOracle(creator) {
        creator = msg.sender;
    }

    function getClientData(address _client, uint64 _index) constant returns (uint256, uint256) {
        ClientData client = clients[_client];
        return (client.clientCost, client.clientPayout, client.duration);
    }

    function getQuote(bytes32 _macbookModel) returns (uint64) { //oracle determines pricing, toy pricing scheme here; I imagine this will normally be off-chain
        ClientData memory newData;
        switch (_macbookModel) {
            case "2017":
            {
            newData.clientCost = "100";
            newData.clientPayout = "2000";
                break;
            }
            case "2016":
            {
                newData.clientCost = "90";
                newData.clientPayout = "1800";
                break;
            }
            default:
            {
                throw;
            }
        }
        newClient.duration = 1000;
        newClient.exists = true;
        let userDataIndex = dataIndex;
        clients[userDataIndex] = newData;
        clientData[msg.sender].push(userDataIndex);
        dataIndex++;
        return userDataIndex;
    }

    function hookInsuranceContract(address _client) returns (bool) {
        if (clients[_client].exists) {
            InsuranceBase contract = InsuranceBase(msg.sender);
            if (contract) {
                clients[_client].contract = contract;
            }
        }
    }

    function payoutClient(address _client) { //oracle has determined that this client's insurance claim is valid
        if (msg.sender != creator) {
            throw;
        }
        if (clients[_client].exists) {
            clients[_client].paidOut = true;
            contract.payoutClient(_client, clients[_client].clientPayout);
            return true;
        }
        return false;
    }
}

contract Syndiacte {
    address owner = msg.sender;

    struct InsuranceInstance {
        address client;
        address orcale;
        uint64  quoteId;
        uint256 clientCost;
        uint256 clientPayout;
        uint256 expiryBlock;
    }

    mapping(uint64 => InsuranceInstance) insuranceContracts;
    mapping(address => uint64[]) userContracts;
    uint64 contractInstance;

    //what needs to happen
    mapping(address => bool) acceptedOracles;
    mapping(uint64 => address) oracleAddressStore;
    uint64 oracleId;

    function getOracles() constant returns address[] {
        for ()
    }

 

    uint256 totalBalance;
    uint256 totalDividends;
    uint256 totalPayouts;

    function addOracle(address oracleAddress) {
        Oracle oracle = Oracle.at(oracleAddress);
        if (oracle) {
            acceptedOracles[oracleAddress] = true;
        } //??
    }

    function insureClient(addresss _oracle, address _client, uint64 _oracleQuote) {
        
        if (!acceptedOracles[_oracle] {
            throw;
        }
        Oracle oracle = Oracle(_oracle);
        if (oracle.creator != msg.sender) {
            throw;
        }
        if (!oracle) {
            throw;
        }
        var (clientCost, clientPayout, endBlock) = oracle.getClientData(_client, _oracleDataIndex);
        if (clientCost > 0 && clientPayout > 0 && clientCost < balance[_client] && clientPayout < totalBalance) {
            InsuranceInstance memory insuranceInstance;
            insuranceInstance.client = _client;
            insuranceInstance.oracle = _oracle;
            insuranceInstance.oracleDataIndex = _oracleDataIndex;
            insuranceInstance.clientCost = clientCost;
            insuranceInstance.clientPayout = clientPayout;
            insuranceInstance.expiryBlock = endBlock;
            insuranceContracts[_client].push(insuranceInstance);
            updateBalance(_client);
            balance[_client] -= clientCost;
{'fraction_non_alphanumeric': 0.0845563332580718, 'fraction_numerical': 0.02099796793858659, 'mean_word_length': 2.118268215417107, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6108216', 'n_tokens_mistral': 2448, 'n_tokens_neox': 2268, 'n_words': 547}