diff --git a/lib/node.js b/lib/node.js index 446101b..c3ca9fa 100644 --- a/lib/node.js +++ b/lib/node.js @@ -76,6 +76,7 @@ function Node() txDensity: [], blockTimes: [], gasSpending: [], + miners: [], uptime: 0, errors: [] }; @@ -235,6 +236,7 @@ Node.prototype.getLatestBlocks = function() this.stats.difficulty = this.difficultyChart(); this.stats.txDensity = this.txDensityChart(); this.stats.gasSpending = this.gasSpendingChart(); + this.stats.miners = this.minersChart(); } Node.prototype.addBlockHistory = function(block) @@ -297,6 +299,22 @@ Node.prototype.gasSpendingChart = function() }); } +Node.prototype.minersChart = function() +{ + var miners = _.countBy(this.blocks, function(block) + { + return block.miner; + }); + + var minersArray = []; + + _.forEach(miners, function(cnt, miner) { + minersArray.push({miner: miner, blocks: cnt}); + }); + + return _.sortBy(minersArray, 'blocks').reverse(); +} + Node.prototype.uptime = function() { this.stats.uptime = ((this._tries - this._down) / this._tries) * 100;