fixed nodes propagation chart and average for nodes out of date

This commit is contained in:
cubedro
2015-05-19 07:55:51 +03:00
parent 88ca0b1d50
commit 64e7ca085e
6 changed files with 52 additions and 7 deletions

View File

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