I've been trying to run two contracts on a private net, using oraclize brigde. First one runs perfectly, however the second one for some reason doesn't call the callback function (despite having sent a query) unless I delete some of the code from the function. Here is the problematic part of the code from it:
pragma solidity ^0.4.16;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
import "github.com/Arachnid/solidity-stringutils/strings.sol";
contract CFDBroker is usingOraclize {
using strings for *;
mapping (uint => uint) instruments;
mapping (bytes32 => uint) queries;
uint public GOLD;
uint public EURUSD;
uint public DJI;
////////////////////////////////////////////////////////////////////////////////
function sendFunds() payable {
getData();
}
////////////////////////////////////////////////////////////////////////////////
function __callback(bytes32 myid, string result, bytes proof) {
require(msg.sender == oraclize_cbAddress());
if (queries[myid] == 1){
//parse and update gold
var s = result.toSlice();
GOLD = parseInt(s.beyond("$".toSlice()).until("/".toSlice()).toString())*100;
instruments[1] = GOLD;
} else{
if(queries[myid] == 2){
//parse and update eur/usd
s = result.toSlice();
var r = result.toSlice().beyond(".".toSlice());
EURUSD = parseInt(s.beyond("$".toSlice()).until(".".toSlice()).concat(r));
instruments[2] = EURUSD;
} else{
if(queries[myid] == 3){
//update DJI
DJI = parseInt(result)*100;
instruments[3]=DJI;
}
}
}
update();
//getData(); --supposed source of the problem
}
/**
* Instrument IDs:
* 0 - ASK FOR ALL
* 1 - GOLD
* 2 - EUR/USD
* 3 - DJI
*/
function getData() private{
queries[oraclize_query(50, "WolframAlpha","gold price in usd")] = 1; //ask for gold
queries[oraclize_query(50, "WolframAlpha","eur/usd")] = 2; // ask for eur/usd
queries[oraclize_query(50, "WolframAlpha","DJI price")] = 3; //ask for DJI
}}
It's a model of a CFD broker, the quoted part is supposed to update prices of 3 financial instruments every 60 seconds. It works fine, when getData() in callback is commented. All in all, it seems very similar to this problem: link.
The contract is a part of my student project, I'd be very grateful for any help :).