2015-05-24 13:04:44 +00:00
|
|
|
|
|
|
|
setInterval(function() {
|
2015-05-24 13:36:19 +00:00
|
|
|
|
|
|
|
var minimalAmount = (web3.eth.getBalance(web3.eth.coinbase) >= 1500000000000000000);
|
2015-05-24 20:46:35 +00:00
|
|
|
var pendingTransactions = web3.eth.pendingTransactions().length > 0;
|
|
|
|
|
|
|
|
if(!web3.eth.mining && (!minimalAmount || pendingTransactions)) {
|
|
|
|
if (!minimalAmount) { console.log("=== minimal ether amount not reached yet") }
|
|
|
|
if (pendingTransactions) { console.log("=== there are pending transactions") }
|
|
|
|
console.log("=== start mining");
|
2015-05-24 13:04:44 +00:00
|
|
|
admin.miner.start();
|
|
|
|
}
|
2015-06-05 03:52:07 +00:00
|
|
|
else if (web3.eth.mining && minimalAmount && !pendingTransactions) {
|
2015-05-24 20:46:35 +00:00
|
|
|
if (minimalAmount) { console.log("=== minimal ether amount reached") }
|
2015-06-05 03:52:07 +00:00
|
|
|
if (!pendingTransactions) { console.log("=== no pending transactions") }
|
2015-05-24 20:46:35 +00:00
|
|
|
console.log("=== stop mining");
|
2015-05-24 13:04:44 +00:00
|
|
|
admin.miner.stop();
|
|
|
|
}
|
|
|
|
}, 1000)
|
|
|
|
|