improve mine script

This commit is contained in:
Iuri Matias 2015-05-24 16:46:35 -04:00
parent b1bc70f2c1
commit 48f773c2e2
1 changed files with 10 additions and 2 deletions

View File

@ -2,10 +2,18 @@
setInterval(function() {
var minimalAmount = (web3.eth.getBalance(web3.eth.coinbase) >= 1500000000000000000);
if(!web3.eth.mining && (!minimalAmount || web3.eth.pendingTransactions().length > 0)) {
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");
admin.miner.start();
}
else {
else if (web3.eth.mining && minimalAmount && minimalAmount) {
if (minimalAmount) { console.log("=== minimal ether amount reached") }
if (pendingTransactions) { console.log("=== no pending transactions") }
console.log("=== stop mining");
admin.miner.stop();
}
}, 1000)