I want to invoke 2 different orcalized queries from the same contract. I saw a few posts but none of the answer works. Is there any way we can do that? Here is my contract. I was expecting this contract to log both 11111111 and 222222222222222 but it prints error VM Exception: invalid opcode I am using http://dapps.oraclize.it/ . When I call single query it works but not 2 queries.
pragma solidity ^0.4.0;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
import "github.com/Arachnid/solidity-stringutils/strings.sol";
contract verifySettlement is usingOraclize {
uint public price;
string public landingtime;
string public expectedtime;`
string public tempvalue;
mapping(bytes32 => uint) queries;
event Log(string text);
function verifySettlement() payable {
Log("Contract created.");
getActualFlightDetails();
getExpectedFlightDetails();
}
function getActualLandingHour() constant returns (string) {
return landingtime;
}
function getExpectedLandingHour() constant returns (string) {
return expectedtime;
}
function __callback(bytes32 _myid, string _result) {
require (msg.sender == oraclize_cbAddress());
if(queries[_myid] == 1)
{
Log("1111111111111111111111111");
}
if(queries[_myid] == 2)
{
Log("2222222222222222222222222222222");
}
//Log(_result);
//tempvalue = _result;
}
function getActualFlightDetails() payable {
Log("Oraclize query was sent, waiting for the answer for getting actual flight details..");
queries[oraclize_query("URL","http://169.53.241.139:5000/actual/flight/1")]=1;
//queries[oraclize_query("URL","http://169.53.241.139:5000/expected/flight/1")]=2;
}
function getExpectedFlightDetails() payable {
Log("Oraclize query was sent, waiting for the answer for getting actual flight details..");
//queries[oraclize_query("URL","http://169.53.241.139:5000/expected/flight/1")]=1;
queries[oraclize_query("URL","http://169.53.241.139:5000/expected/flight/1")]=2;
}
}