Essentially, is there a SetTimeout in Solidity?
creationTime = now;
lastBlockNumberA = block.number - 1;
first = lastBlockNumberA;
if(now >= creationTime + 1 days){
lastBlockNumberB = block.number - 1;
second = lastBlockNumberB;
if(first == second){
doSomething();
}
}
function doSomething(){ };
Assuming a block has been mined over the course of the time period, does first == second? Does the doSomething function fire?
Preferably, is there a way to wait (x) number of blocks before running the if statement? I would like to wait a certain number of blocks (or time) before I get a new lastBlockNumber- is it even possible (without invoking the contract again - just from the one contract invocation, in this example 1 day ago).
From my tests it would appear as though the invocation of a contract does not allow for functions/if statements within it to be called (x) units of time or blocks in the future, without having to invoke the contract again, is that correct? If not, how would one do that?
I found this: https://solidity.readthedocs.org/en/latest/common-patterns.html#state-machine
It talks of stages, but does one have to interact with the contract to perform the stage 'guard tests' or do these happen automatically regardless?
return first;will never execute. This is probably not what you mean, so can you clarify your question by providing a larger snippit from your contract? – J-B Feb 06 '16 at 02:59