added block method for socket
This commit is contained in:
parent
12c089cc10
commit
db462b13c2
@ -181,6 +181,32 @@ netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "block":
|
||||||
|
var index = findIndex({id: data.id});
|
||||||
|
|
||||||
|
if( index >= 0 && !_.isUndefined($scope.nodes[index]) && !_.isUndefined($scope.nodes[index].stats) )
|
||||||
|
{
|
||||||
|
if( $scope.nodes[index].stats.block.number < data.block.number )
|
||||||
|
{
|
||||||
|
var best = _.max($scope.nodes, function (node) {
|
||||||
|
return parseInt(node.stats.block.number);
|
||||||
|
}).stats.block;
|
||||||
|
|
||||||
|
if (data.block.number > best.number) {
|
||||||
|
data.block.arrived = _.now();
|
||||||
|
} else {
|
||||||
|
data.block.arrived = best.arrived;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.nodes[index].history = data.history;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.nodes[index].stats.block = data.block;
|
||||||
|
$scope.nodes[index].stats.propagationAvg = data.propagationAvg;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case "pending":
|
case "pending":
|
||||||
var index = findIndex({id: data.id});
|
var index = findIndex({id: data.id});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user