From 48f773c2e2e9b57ddece7be95dba3cb2ddcdd4e0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 24 May 2015 16:46:35 -0400 Subject: [PATCH] improve mine script --- js/mine.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/mine.js b/js/mine.js index 053e0968b..8904f291f 100644 --- a/js/mine.js +++ b/js/mine.js @@ -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)