fixed block time math
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
body {
|
||||
min-width: 1920px;
|
||||
min-width: 1900px;
|
||||
font-smooth: auto;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-font-smoothing: antialiased;
|
||||
|
||||
@@ -124,50 +124,55 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
return node.stats.active == true;
|
||||
}).length;
|
||||
|
||||
$scope.bestBlock = _.max($scope.nodes, function(node) {
|
||||
var bestBlock = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.block.number;
|
||||
|
||||
$scope.lastBlock = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.timestamp);
|
||||
}).stats.block.timestamp;
|
||||
if(bestBlock > $scope.bestBlock)
|
||||
{
|
||||
$scope.bestBlock = bestBlock;
|
||||
|
||||
$scope.lastBlock = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.block.received;
|
||||
|
||||
$scope.lastBlocksTime = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.blockTimes;
|
||||
|
||||
jQuery('.spark-blocktimes').sparkline($scope.lastBlocksTime.reverse(), {type: 'bar', tooltipSuffix: 's'});
|
||||
|
||||
$scope.difficultyChange = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.difficulty;
|
||||
|
||||
jQuery('.spark-difficulty').sparkline($scope.difficultyChange.reverse(), {type: 'bar'});
|
||||
|
||||
$scope.transactionDensity = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.txDensity;
|
||||
|
||||
jQuery('.spark-transactions').sparkline($scope.transactionDensity.reverse(), {type: 'bar'});
|
||||
|
||||
$scope.gasSpending = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.gasSpending;
|
||||
|
||||
jQuery('.spark-gasspending').sparkline($scope.gasSpending.reverse(), {type: 'bar'});
|
||||
}
|
||||
|
||||
$scope.lastDifficulty = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.timestamp);
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.block.difficulty;
|
||||
|
||||
$scope.avgBlockTime = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.timestamp);
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.blocktimeAvg;
|
||||
|
||||
$scope.upTimeTotal = _.reduce($scope.nodes, function(total, node) {
|
||||
return total + node.stats.uptime;
|
||||
}, 0) / $scope.nodes.length;
|
||||
|
||||
$scope.lastBlocksTime = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.blockTimes;
|
||||
|
||||
jQuery('.spark-blocktimes').sparkline($scope.lastBlocksTime, {type: 'bar', tooltipSuffix: 's'});
|
||||
|
||||
$scope.difficultyChange = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.difficulty;
|
||||
|
||||
jQuery('.spark-difficulty').sparkline($scope.difficultyChange, {type: 'bar'});
|
||||
|
||||
$scope.transactionDensity = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.txDensity;
|
||||
|
||||
jQuery('.spark-transactions').sparkline($scope.transactionDensity, {type: 'bar'});
|
||||
|
||||
$scope.gasSpending = _.max($scope.nodes, function(node) {
|
||||
return parseInt(node.stats.block.number);
|
||||
}).stats.gasSpending;
|
||||
|
||||
jQuery('.spark-gasspending').sparkline($scope.gasSpending, {type: 'bar'});
|
||||
|
||||
$scope.map = _.map($scope.nodes, function(node) {
|
||||
if(node.geo != null)
|
||||
return {
|
||||
|
||||
@@ -75,7 +75,9 @@ angular.module('netStatsApp.filters', [])
|
||||
};
|
||||
})
|
||||
.filter('propagationTimeClass', function() {
|
||||
return function(propagation) {
|
||||
return function(arrival, best) {
|
||||
var propagation = arrival - best;
|
||||
|
||||
if(propagation <= 3000)
|
||||
return 'text-success';
|
||||
|
||||
@@ -112,8 +114,9 @@ angular.module('netStatsApp.filters', [])
|
||||
if(timestamp === 0)
|
||||
return '∞';
|
||||
|
||||
var time = Math.floor((new Date()).getTime() / 1000);
|
||||
var diff = time - timestamp;
|
||||
// var time = Math.floor((new Date()).getTime() / 1000);
|
||||
var time = (new Date()).getTime();
|
||||
var diff = Math.floor((time - timestamp)/1000);
|
||||
|
||||
if(diff < 60)
|
||||
return Math.round(diff) + ' s ago';
|
||||
@@ -122,7 +125,8 @@ angular.module('netStatsApp.filters', [])
|
||||
};
|
||||
})
|
||||
.filter('blockPropagationFilter', function() {
|
||||
return function(ms) {
|
||||
return function(arrival, best) {
|
||||
var ms = arrival - best;
|
||||
var result = 0;
|
||||
|
||||
if(ms < 1000) {
|
||||
@@ -210,7 +214,8 @@ function peerClass(peers)
|
||||
|
||||
function timeClass(timestamp)
|
||||
{
|
||||
var time = Math.floor((new Date()).getTime() / 1000);
|
||||
// var time = Math.floor((new Date()).getTime() / 1000);
|
||||
var time = (new Date()).getTime();
|
||||
var diff = time - timestamp;
|
||||
|
||||
return blockTimeClass(diff);
|
||||
|
||||
Reference in New Issue
Block a user