1

Is it possible to run simultaneously oraclase query? Because i have a probleme with this function:

 function closePhase1(uint contestID) payable MustBePhase1(contestID) ownerOrOrganiserOnly(contestID) {
    contests[contestID].phase = 2;

    for (uint i = 0 ; i < contests[contestID].nbVideos ; i++) {
        string ytID = contests[contestID].videos[i].youtubeID;
        debugStr(ytID);
        oraclize_query('URL', 'html(https://www.youtube.com/watch?v='.toSlice().concat(ytID.toSlice()).toSlice().concat(').xpath(concat("['.toSlice()).toSlice().concat(ytID.toSlice()).toSlice().concat(']", //*[contains(@class, "watch-view-count")]/text()))'.toSlice()));  

    }
    debugStr('Demand send to oracle...');

}

1 Answer 1

1

Yes, it is indeed possible to request multiple queries to be processed by way of a for loop even. Just ensure, you have enough to cover the cost for each query call, as each one will be charged separately. Also, ensure the number of times the loop iterates, still allows it to stay below the gas limit, as it may be failing because it's running out of gas.

I also see you're converting the strings to a slice(probably using the strings library), ensure you are converting back to string, before the actual oraclize_query method call.

2
  • Thanks but when I call g_contract.closePhase1(contestID, {from: addressUser, gas:4000000, value: web3.toWei(2, "ether")}, function(err, result) { alert(err); callbackfunction(result); }); I have an error : "Error: VM Exception while processing transaction: invalid opcode" But if I comment the query line i have no error Commented Jul 7, 2017 at 8:32
  • As mentioned, are you converting the slice object you are using back to a string? You need to call .toString() on the whole slice object before sending it to oraclize.
    – DenisM
    Commented Jul 7, 2017 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.