added miners chart

This commit is contained in:
cubedro 2015-04-06 02:20:14 +03:00
parent 4cc7d88235
commit 7f2f722d5d

View File

@ -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;