improved arrival time
This commit is contained in:
parent
51ab249429
commit
7d0994dc24
@ -23,9 +23,7 @@ Collection.prototype.update = function(id, stats)
|
|||||||
if(!node)
|
if(!node)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
node.stats = stats;
|
return node.setStats(stats);
|
||||||
|
|
||||||
return node.getStats();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection.prototype.inactive = function(id)
|
Collection.prototype.inactive = function(id)
|
||||||
|
@ -18,7 +18,8 @@ var Node = function Node(data)
|
|||||||
gasLimit: 0,
|
gasLimit: 0,
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
arrival: 0,
|
arrival: 0,
|
||||||
propagation: 0
|
propagation: 0,
|
||||||
|
received: 0
|
||||||
},
|
},
|
||||||
blocktimeAvg: 0,
|
blocktimeAvg: 0,
|
||||||
blockTimes: [],
|
blockTimes: [],
|
||||||
@ -72,6 +73,24 @@ Node.prototype.getInfo = function()
|
|||||||
return {id: this.id, info: this.info, geo: this.geo, stats: this.stats};
|
return {id: this.id, info: this.info, geo: this.geo, stats: this.stats};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node.prototype.setStats = function(stats)
|
||||||
|
{
|
||||||
|
if(typeof stats !== undefined && typeof stats.block !== undefined && typeof stats.block.number !== undefined)
|
||||||
|
{
|
||||||
|
if(stats.block.number !== this.stats.number){
|
||||||
|
stats.block.received == (new Date()).getTime() - stats.block.arrival;
|
||||||
|
} else {
|
||||||
|
stats.block.received = this.stats.block.received;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.stats = stats;
|
||||||
|
|
||||||
|
return this.getStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Node.prototype.getStats = function()
|
Node.prototype.getStats = function()
|
||||||
{
|
{
|
||||||
return {id: this.id, stats: this.stats};
|
return {id: this.id, stats: this.stats};
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "0.12.0",
|
"node": "0.12.0",
|
||||||
"npm": "2.5.0"
|
"npm": "2.5.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www"
|
"start": "node ./bin/www"
|
||||||
|
@ -69,13 +69,6 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "update":
|
case "update":
|
||||||
if(typeof $scope.nodes[findIndex({id: data.id})].stats !== 'undefined' && typeof $scope.nodes[findIndex({id: data.id})].stats.block !== 'undefined'){
|
|
||||||
if($scope.nodes[findIndex({id: data.id})].stats.block.number != data.stats.block.number){
|
|
||||||
data.stats.block.when = (new Date()).getTime() - data.stats.block.arrival;
|
|
||||||
} else {
|
|
||||||
data.stats.block.when = $scope.nodes[findIndex({id: data.id})].stats.block.when;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$scope.nodes[findIndex({id: data.id})].stats = data.stats;
|
$scope.nodes[findIndex({id: data.id})].stats = data.stats;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -116,7 +116,6 @@ angular.module('netStatsApp.filters', [])
|
|||||||
})
|
})
|
||||||
.filter('blockPropagationFilter', function() {
|
.filter('blockPropagationFilter', function() {
|
||||||
return function(ms) {
|
return function(ms) {
|
||||||
// ms = (new Date()).getTime() - ms;
|
|
||||||
var result = 0;
|
var result = 0;
|
||||||
|
|
||||||
if(ms < 1000) {
|
if(ms < 1000) {
|
||||||
|
@ -128,5 +128,5 @@ block content
|
|||||||
//- div.small Difficulty: {{node.stats.block.difficulty | gasFilter}} | Gas used: {{node.stats.block.gasUsed | gasFilter}} | Min gas price: {{node.stats.block.minGasPrice | gasFilter}} | Gas limit: {{node.stats.block.gasLimit | gasFilter}}
|
//- div.small Difficulty: {{node.stats.block.difficulty | gasFilter}} | Gas used: {{node.stats.block.gasUsed | gasFilter}} | Min gas price: {{node.stats.block.minGasPrice | gasFilter}} | Gas limit: {{node.stats.block.gasLimit | gasFilter}}
|
||||||
td(style="padding-left: 18px;") {{node.stats.block.txCount}}
|
td(style="padding-left: 18px;") {{node.stats.block.txCount}}
|
||||||
td(class="{{ node.stats.block.timestamp | timeClass }}") {{node.stats.block.timestamp | blockTimeFilter }}
|
td(class="{{ node.stats.block.timestamp | timeClass }}") {{node.stats.block.timestamp | blockTimeFilter }}
|
||||||
td(class="{{ node.stats.block.when | propagationTimeClass }}") {{node.stats.block.when | blockPropagationFilter}}
|
td(class="{{ node.stats.block.received | propagationTimeClass }}") {{node.stats.block.received | blockPropagationFilter}}
|
||||||
td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }}
|
td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }}
|
||||||
|
Loading…
Reference in New Issue
Block a user