improved hashrate accuracy

This commit is contained in:
cubedro 2015-04-28 14:04:39 +03:00
parent 5963eb5a80
commit 4c76139909
3 changed files with 37 additions and 10 deletions

View File

@ -272,6 +272,32 @@ History.prototype.getGasSpending = function()
return gasSpending;
}
History.prototype.getAvgHashrate = function()
{
if(this._items.length === 0)
return 0;
var difficultyHistory = _(this._items)
.map(function(item)
{
return item.block.difficulty;
})
.value();
var avgDifficulty = _.sum(difficultyHistory)/difficultyHistory.length;
var blocktimeHistory = _(this._items)
.map(function(item)
{
return item.block.time;
})
.value();
var avgBlocktime = _.sum(blocktimeHistory)/blocktimeHistory.length;
return avgDifficulty/1000 * 12 * (12/avgBlocktime);
}
History.prototype.getCharts = function()
{
var chartHistory = _(this._items)
@ -301,7 +327,8 @@ History.prototype.getCharts = function()
transactions: _.pluck(chartHistory, 'transactions'),
gasSpending: _.pluck(chartHistory, 'gasSpending'),
propagation: this.getBlockPropagation(),
uncleCount: this.getUncleCount()
uncleCount: this.getUncleCount(),
avgHashrate: this.getAvgHashrate()
}
return chart;

View File

@ -155,7 +155,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
case "charts":
$scope.lastBlocksTime = data.blocktime;
$scope.avgBlockTime = data.avgBlocktime;
$scope.avgHashrate = $scope.lastDifficulty / 1000000 * data.avgBlocktime;
$scope.avgHashrate = data.avgHashrate;
$scope.difficultyChart = data.difficulty;
$scope.transactionDensity = data.transactions;
$scope.gasSpending = data.gasSpending;

View File

@ -27,14 +27,6 @@ block content
span.small-title best block
span.big-details {{'#'}}{{ bestBlock | number}}
div.clearfix
div.col-xs-2.stat-holder
div.big-info.difficulty.text-orange
div.pull-left.icon-full-width
i.icon-hashrate
div.pull-left
span.small-title avg hashrate
span.big-details {{ avgHashrate | number : 1 }} MH/s
div.clearfix
div.col-xs-2.stat-holder
div.big-info.uncleCount.text-info
div.pull-left.icon-full-width
@ -60,6 +52,14 @@ block content
span.small-title avg block time
span.big-details {{ avgBlockTime | avgTimeFilter }}
div.clearfix
div.col-xs-2.stat-holder
div.big-info.difficulty.text-orange
div.pull-left.icon-full-width
i.icon-hashrate
div.pull-left
span.small-title avg network hashrate
span.big-details {{ avgHashrate | number : 1 }} MH/s
div.clearfix
div.clearfix