fixed nodes propagation chart and average for nodes out of date
This commit is contained in:
parent
88ca0b1d50
commit
64e7ca085e
2
dist/index.html
vendored
2
dist/index.html
vendored
File diff suppressed because one or more lines are too long
2
dist/js/netstats.min.js
vendored
2
dist/js/netstats.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/netstats.min.js.map
vendored
2
dist/js/netstats.min.js.map
vendored
File diff suppressed because one or more lines are too long
@ -158,22 +158,33 @@ History.prototype.getNodePropagation = function(id)
|
||||
{
|
||||
var propagation = new Array( MAX_PEER_PROPAGATION );
|
||||
var bestBlock = this.bestBlockNumber();
|
||||
var lastBlocktime = _.now();
|
||||
|
||||
_.fill(propagation, -1);
|
||||
|
||||
var sorted = _( this._items )
|
||||
.sortByOrder( 'height', false )
|
||||
.slice( 0, MAX_PEER_PROPAGATION )
|
||||
.reverse()
|
||||
.forEach(function (item, key)
|
||||
{
|
||||
var index = MAX_PEER_PROPAGATION - 1 - bestBlock + item.height;
|
||||
|
||||
if(index > 0)
|
||||
if(index >= 0)
|
||||
{
|
||||
propagation[index] = _.result(_.find(item.propagTimes, 'node', id), 'propagation', -1);
|
||||
var tmpPropagation = _.result(_.find(item.propagTimes, 'node', id), 'propagation', false);
|
||||
|
||||
if (_.result(_.find(item.propagTimes, 'node', id), 'propagation', false) !== false)
|
||||
{
|
||||
propagation[index] = tmpPropagation;
|
||||
lastBlocktime = item.block.arrived;
|
||||
}
|
||||
else
|
||||
{
|
||||
propagation[index] = Math.max(0, lastBlocktime - item.block.arrived);
|
||||
}
|
||||
}
|
||||
})
|
||||
.reverse()
|
||||
.value();
|
||||
|
||||
return propagation;
|
||||
|
@ -356,6 +356,40 @@ angular.module('netStatsApp.filters', [])
|
||||
return prefix + Math.round(result) + " days";
|
||||
};
|
||||
})
|
||||
.filter('blockPropagationAvgFilter', function() {
|
||||
return function(stats, bestBlock) {
|
||||
var ms = stats.propagationAvg;
|
||||
|
||||
if(bestBlock - stats.block.number > 40)
|
||||
ms = _.now() - stats.block.received;
|
||||
|
||||
prefix = '';
|
||||
|
||||
var result = 0;
|
||||
|
||||
if(ms < 1000) {
|
||||
return (ms === 0 ? "" : prefix) + ms + " ms";
|
||||
}
|
||||
|
||||
if(ms < 1000*60) {
|
||||
result = ms/1000;
|
||||
return prefix + result.toFixed(1) + " s";
|
||||
}
|
||||
|
||||
if(ms < 1000*60*60) {
|
||||
result = ms/1000/60;
|
||||
return prefix + Math.round(result) + " min";
|
||||
}
|
||||
|
||||
if(ms < 1000*60*60*24) {
|
||||
result = ms/1000/60/60;
|
||||
return prefix + Math.round(result) + " h";
|
||||
}
|
||||
|
||||
result = ms/1000/60/60/24;
|
||||
return prefix + Math.round(result) + " days";
|
||||
};
|
||||
})
|
||||
.filter('avgTimeFilter', function() {
|
||||
return function(time) {
|
||||
if(time < 60)
|
||||
|
@ -209,5 +209,5 @@ block content
|
||||
div.propagationBox
|
||||
span {{node.stats.block.propagation | blockPropagationFilter}}
|
||||
td.peerPropagationChart(class="{{node.id}}")
|
||||
td(class="{{ node.stats | propagationNodeAvgTimeClass : bestBlock }}") {{ node.stats.propagationAvg | blockPropagationFilter : '' }}
|
||||
td(class="{{ node.stats | propagationNodeAvgTimeClass : bestBlock }}") {{ node.stats | blockPropagationAvgFilter : bestBlock }}
|
||||
td(class="{{ node.stats.uptime | upTimeClass : node.stats.active }}") {{ node.stats.uptime | upTimeFilter }}
|
||||
|
Loading…
Reference in New Issue
Block a user