diff --git a/lib/node.js b/lib/node.js index 5ad9dc1..849c397 100644 --- a/lib/node.js +++ b/lib/node.js @@ -70,6 +70,7 @@ function Node() difficulty: [], txDensity: [], blockTimes: [], + gasSpending: [], uptime: 0, errors: [] }; @@ -222,6 +223,7 @@ Node.prototype.getLatestBlocks = function() this.stats.blocktimeAvg = this.blockTimesAvg(); this.stats.difficulty = this.difficultyChart(); this.stats.txDensity = this.txDensityChart(); + this.stats.gasSpending = this.gasSpendingChart(); } Node.prototype.addBlockHistory = function(block) @@ -276,6 +278,14 @@ Node.prototype.txDensityChart = function() }); } +Node.prototype.gasSpendingChart = function() +{ + return gasSpending = _.map(this.blocks, function(block) + { + return block.gasUsed; + }); +} + Node.prototype.uptime = function() { this.stats.uptime = ((this._tries - this._down) / this._tries) * 100; @@ -294,7 +304,11 @@ Node.prototype.getStats = function() if(this.stats.block.number > 0) this.getLatestBlocks(); - self.stats.pending = web3.eth.getBlockTransactionCount('pending'); + try { + this.stats.pending = web3.eth.getBlockTransactionCount('pending'); + } catch (err) { + console.error(err); + } this.stats.mining = web3.eth.mining; this.stats.gasPrice = web3.eth.gasPrice.toString(10); this.stats.listening = web3.net.listening;