Scheduler doesn't work

Andy1982Andy1982 Member Posts: 2
I need to make a demo app using scheduler v0.7 (http://www.ethereum-alarm-clock.com/source/v0.7.0/)
Code sample as below. function callback doesn't get invoked as expected in next 20 blocks. I deployed this contract in test environment.
contract SchedulerInterface {
function scheduleCall(bytes4 abiSignature,
uint targetBlock,
uint requiredGas) public returns (address);
}

contract LazyContract {
uint public aliveSince;
uint public lastHeartbeat;
uint public heartbeatCount;
uint public targetBlock;
SchedulerInterface scheduler;

address public owner;

uint16 public frequency;

function LazyContract() {
owner = msg.sender;
scheduler = SchedulerInterface(0x26416b12610d26fd31d227456e9009270574038f);
frequency = 20;
aliveSince = 0;
}

function() {
if (this.balance < 2 ether) {
owner.send(this.balance);
}
}

function initialize() public returns(uint ret) {
// ensure we are not already initialized.
if (aliveSince != 0) return aliveSince;

// mark when the canary came to life.
aliveSince = now;

// schedule the first call
StartScheduler();

return aliveSince;
}

function StartScheduler() public {
targetBlock = block.number + frequency;

scheduler.scheduleCall.value(this.balance)(
bytes4(sha3("callback()")),
targetBlock,
2000000);
}

function callback() public {
heartbeatCount += 1;
lastHeartbeat = now;
}
}

Anyone can help me out?

Comments

Sign In or Register to comment.