diff --git a/lib/node.js b/lib/node.js index 3e731c4..71fc2bf 100644 --- a/lib/node.js +++ b/lib/node.js @@ -42,6 +42,7 @@ function Node() block: {}, blocktimeAvg: 0, difficulty: [], + txDensity: [], uptime: 0, errors: [] }; @@ -145,6 +146,13 @@ Node.prototype.getBlock = function(number) if(block.hash != '?' && typeof block.difficulty !== 'undefined') { block.difficulty = web3.toDecimal(block.difficulty); + + try { + block.txCount = web3.eth.transactionCount(block.hash); + } + catch (err) { + console.log(err); + } } } catch (err) { @@ -180,6 +188,7 @@ Node.prototype.getLatestBlocks = function() this.calculateBlockTimes(); this.stats.blocktimeAvg = this.blockTimesAvg(); this.stats.difficulty = this.difficultyChart(); + this.stats.txDensity = this.txDensityChart(); } Node.prototype.addBlockHistory = function(block) @@ -227,6 +236,14 @@ Node.prototype.difficultyChart = function() }); } +Node.prototype.txDensityChart = function() +{ + return txDensity = _.map(this.blocks, function(block) + { + return block.txCount; + }); +} + Node.prototype.uptime = function() { this.stats.uptime = ((this._tries - this._down) / this._tries) * 100;