I want to create a contract, which has a deposit function.
But I also want, in the constructor, to start a "thread" that polls an external data source (via oraclize/chainlink or similar) at certain frequency.
Or instead of setting up a loop, should I just call each new block ?
contract SimpleOraclizeContract is usingOraclize {
function SimpleOraclizeContract() {
// something like this in java
new thread().run(new Runnable(){
while(true){
sleep(10);
if(oraclize_getPrice() > 100) {
doSomething();
}
}
})
}
function updatePrice() payable {
if (oraclize_getPrice("URL") > this.balance) {
LogNewOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
} else {
LogNewOraclizeQuery("Oraclize query was sent, standing by for the answer..");
oraclize_query("URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHXBT).result.XETHXXBT.c.0");
}
}
Given the above code how could I call oraclize_getPrice("URL") (which I assume is inherited) every for 10 seconds, or every new block ? Completely outside of a payable function.