From 119500bbcb478a675bcc471f006d907700922999 Mon Sep 17 00:00:00 2001 From: cubedro Date: Fri, 24 Apr 2015 01:37:42 +0300 Subject: [PATCH] added hashrate --- lib/node.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/node.js b/lib/node.js index 7793a29..9ae75db 100644 --- a/lib/node.js +++ b/lib/node.js @@ -79,6 +79,7 @@ function Node() active: false, listening: false, mining: false, + hashrate: 0, peers: 0, pending: 0, gasPrice: 0, @@ -393,6 +394,23 @@ Node.prototype.getStats = function() } this.stats.mining = web3.eth.mining; + + if(this.stats.mining) + { + try { + this.stats.hashrate = web3.eth.hashRate; + } + catch (err) + { + console.error('hashrate: ', err); + this.stats.hashrate = 0; + } + } + else + { + this.stats.hashrate = 0; + } + this.stats.gasPrice = web3.toBigNumber(web3.eth.gasPrice).toString(10); } else { console.error("getStats: couldn't fetch block...");