added node latency
This commit is contained in:
parent
76de55f2e5
commit
6c17d0ee9c
5
app.js
5
app.js
@ -20,6 +20,7 @@ api = new Primus(server, {
|
||||
});
|
||||
|
||||
api.use('emit', require('primus-emit'));
|
||||
api.use('spark-latency', require('primus-spark-latency'));
|
||||
|
||||
var client = new Primus(server, {
|
||||
transformer: 'websockets',
|
||||
@ -30,12 +31,14 @@ var client = new Primus(server, {
|
||||
client.use('emit', require('primus-emit'));
|
||||
|
||||
api.on('connection', function(spark) {
|
||||
console.log('Latency: ', spark.latency);
|
||||
console.log(spark.id);
|
||||
console.log(spark.address);
|
||||
console.log(spark.query);
|
||||
|
||||
spark.on('hello', function(data)
|
||||
{
|
||||
console.log('Latency: ', spark.latency);
|
||||
console.log('got hello data from ', spark.id);
|
||||
console.log(data);
|
||||
|
||||
@ -53,11 +56,13 @@ api.on('connection', function(spark) {
|
||||
|
||||
spark.on('update', function(data)
|
||||
{
|
||||
console.log('Latency: ', spark.latency);
|
||||
console.log('got update from ' + spark.id);
|
||||
console.log(data);
|
||||
|
||||
if(typeof data.id !== 'undefined' && typeof data.stats !== 'undefined')
|
||||
{
|
||||
data.stats.latency = spark.latency;
|
||||
var stats = Nodes.update(data.id, data.stats);
|
||||
|
||||
client.write({action: 'update', data: stats});
|
||||
|
@ -21,6 +21,7 @@ var Node = function Node(data)
|
||||
},
|
||||
blocktimeAvg: 0,
|
||||
difficulty: [],
|
||||
latency: 0,
|
||||
uptime: 0,
|
||||
lastUpdate: 0
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
"lodash": "^3.2.0",
|
||||
"primus": "^2.4.12",
|
||||
"primus-emit": "^0.1.2",
|
||||
"primus-spark-latency": "^0.1.1",
|
||||
"serve-favicon": "~2.1.3",
|
||||
"ws": "^0.7.1"
|
||||
}
|
||||
|
@ -60,6 +60,14 @@ angular.module('netStatsApp.filters', [])
|
||||
return (typeof gas !== 'undefined' ? parseInt(gas) : '?');
|
||||
}
|
||||
})
|
||||
.filter('latencyFilter', function() {
|
||||
return function(stats) {
|
||||
if(stats.active === false)
|
||||
return 'offline';
|
||||
else
|
||||
return stats.latency + ' ms';
|
||||
}
|
||||
})
|
||||
.filter('hashFilter', function() {
|
||||
return function(hash) {
|
||||
return hash.substr(0, 6) + '...' + hash.substr(58, 6);
|
||||
@ -79,7 +87,7 @@ angular.module('netStatsApp.filters', [])
|
||||
var diff = time - timestamp;
|
||||
|
||||
if(diff < 60)
|
||||
return Math.round(diff) + ' s';
|
||||
return Math.round(diff) + ' s ago';
|
||||
|
||||
return moment.duration(Math.round(diff), 's').humanize() + ' ago';
|
||||
};
|
||||
|
@ -77,6 +77,8 @@ block content
|
||||
i.icon-node(data-toggle="tooltip", data-placement="top", title="Node")
|
||||
th
|
||||
i.icon-laptop(data-toggle="tooltip", data-placement="top", title="Node type")
|
||||
th
|
||||
i.icon-gas(data-toggle="tooltip", data-placement="top", title="Node latency")
|
||||
th
|
||||
i.icon-mining(data-toggle="tooltip", data-placement="top", title="Is mining")
|
||||
th
|
||||
@ -100,8 +102,9 @@ block content
|
||||
td
|
||||
div.small(ng-bind-html="node.info.node | nodeVersion")
|
||||
//- div.small {{node.info.os}}, {{node.info.os_v}}
|
||||
td.small(class="{{ node.stats | mainClass : bestBlock }}") {{node.stats | latencyFilter}}
|
||||
td(class="{{ node.stats.mining | miningClass }}")
|
||||
i(class="{{ node.stats.mining | miningIconClass }}")
|
||||
i.small(class="{{ node.stats.mining | miningIconClass }}")
|
||||
td(class="{{ node.stats.peers | peerClass }}", style="padding-left: 18px;") {{node.stats.peers}}
|
||||
td(style="padding-left: 18px;") {{node.stats.pending}}
|
||||
td(class="{{ node.stats.block.number | blockClass : bestBlock }}") {{'#' + node.stats.block.number}}
|
||||
|
Loading…
Reference in New Issue
Block a user