1

I'm using the Oraclize to get the random number for bets. When the function bet() is called and if the oraclize is failed it should call the pingOracle() again. Below is example

function bet() public payable {
    require(msg.value == 0.1 ether);
    pingOracle();
}

function __callback(bytes32 _queryId, string _result, bytes _proof) public onlyOraclize  {

    if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) != 0) {
        oracleFailed = true;
    } else {
        uint randomN = (uint(keccak256(abi.encodePacked(_result))) % (max.sub(min)).add(min));
        revealWinner(randomN);
        oracleFailed = false;
    }

    if(oracleFailed) {
        count = count.add(1);
        pingOracle();
    }
}

function pingOracle() private {
    oraclize_setProof(proofType_Ledger);
    bytes32 queryId = oraclize_newRandomDSQuery(delay, N, gasOraclize); 
}

function revealWinner(uint _index) internal {
    uint amount = pot.sub(amountforTeam).sub(gasOraclize.mul(gasPriceOraclize));
    winner = users[_index];
    winner.transfer(amount);
}

In this code snippet, if there is no proof verification, then the function pingOracle() is called again but when the oraclize is failed for example gasOraclize isn't enough for calling oraclize or by other reasons I can't handle it... So how can I handle it and call the pingOracle() again? Thanks in advance)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.