diff --git a/lib/node.js b/lib/node.js index 0aea334..a948299 100644 --- a/lib/node.js +++ b/lib/node.js @@ -411,17 +411,18 @@ Node.prototype.getStats = function(forced) peers: function (callback) { async.nextTick(function () { - var peers; + var peers = null; + var error = null; try { peers = web3.toDecimal(web3.net.peerCount); } catch (err) { console.error('xx>', 'PeerCount failed: ', err); - callback(err, null); + error = err; } - callback(null, peers); + callback(error, peers); }); }, pending: function (callback) @@ -439,34 +440,36 @@ Node.prototype.getStats = function(forced) mining: function (callback) { async.nextTick(function () { - var mining; + var mining = null; + var error = null; try { mining = web3.eth.mining; } catch (err) { console.error('xx>', 'Mining failed: ', err); - callback(err, null); + error = err; } - callback(null, mining); + callback(error, mining); }); }, hashrate: function (callback) { if(self.stats.mining) { async.nextTick(function () { - var hashrate; + var hashrate = null; + var error = null; try { hashrate = web3.eth.hashrate; } catch (err) { console.error('xx>', 'Hashrate failed: ', err); - callback(err, null); + error = err; } - callback(null, hashrate); + callback(error, hashrate); }); } else { @@ -476,33 +479,35 @@ Node.prototype.getStats = function(forced) gasPrice: function (callback) { async.nextTick(function () { - var gasPrice; + var gasPrice = null; + var error = null; try { gasPrice = web3.toBigNumber(web3.eth.gasPrice).toString(10); } catch (err) { console.error('xx>', 'gasPrice failed: ', err); - callback(err, null); + error = err; } - callback(null, gasPrice); + callback(error, gasPrice); }); }, // minerName: function (callback) // { // async.nextTick(function () { - // var minerName; + // var minerName = null; + // var error = null; // try { // minerName = self.getMinerName(self.stats.block.miner); // } // catch (err) { // console.error('xx>', 'minerName failed: ', err); - // callback(err, null); + // error = err; // } - // callback(null, minerName); + // callback(error, minerName); // }); // } },