From f157b1eacf91a2fcdeeee582793edfc82d9cb21e Mon Sep 17 00:00:00 2001 From: cubedro Date: Thu, 19 Feb 2015 18:19:46 +0200 Subject: [PATCH 01/13] fixed moment js locale --- public/js/lib/locale/en-gb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/lib/locale/en-gb.js b/public/js/lib/locale/en-gb.js index fee3f0d9..2e260a87 100644 --- a/public/js/lib/locale/en-gb.js +++ b/public/js/lib/locale/en-gb.js @@ -37,7 +37,7 @@ future : 'in %s', past : '%s ago', s : 'a few sec', - m : 'a min', + m : '1 min', mm : '%d min', h : '1 h', hh : '%d h', From d74894c99dc91d7cb3d220ddf5bd4687bc3af771 Mon Sep 17 00:00:00 2001 From: cubedro Date: Thu, 19 Feb 2015 19:34:20 +0200 Subject: [PATCH 02/13] compacted block hash --- public/js/filters.js | 5 +++++ views/index.jade | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/public/js/filters.js b/public/js/filters.js index 658f6e2f..2ba0a9a2 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -60,6 +60,11 @@ angular.module('netStatsApp.filters', []) return (typeof gas !== 'undefined' ? parseInt(gas) : '?'); } }) +.filter('hashFilter', function() { + return function(hash) { + return hash.substr(0, 6) + '...' + hash.substr(58, 6); + } +}) .filter('timeClass', function() { return function(timestamp) { return timeClass(timestamp); diff --git a/views/index.jade b/views/index.jade index 04cd27a1..cb818e36 100644 --- a/views/index.jade +++ b/views/index.jade @@ -89,7 +89,7 @@ block content th i.icon-check-o(data-toggle="tooltip", data-placement="top", title="Block transactions") th - i.icon-time(data-toggle="tooltip", data-placement="top", title="Last node time") + i.icon-time(data-toggle="tooltip", data-placement="top", title="Last block time") th i.icon-clock(data-toggle="tooltip", data-placement="top", title="Up-time") tbody @@ -106,7 +106,7 @@ block content td(style="padding-left: 18px;") {{node.stats.pending}} td(class="{{ node.stats.block.number | blockClass : bestBlock }}") {{'#' + node.stats.block.number}} td(class="{{ node.stats.block.number | blockClass : bestBlock }}").hidden-sm.hidden-xs - span.small {{node.stats.block.hash}} + span.small {{node.stats.block.hash | hashFilter}} //- 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(class="{{ node.stats.block.timestamp | timeClass }}") {{node.stats.block.timestamp | blockTimeFilter }} From 76de55f2e5cdf6979add1dd041aebd2dbbff97ca Mon Sep 17 00:00:00 2001 From: cubedro Date: Thu, 19 Feb 2015 22:49:44 +0200 Subject: [PATCH 03/13] added node name to notifications --- public/js/controllers.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/js/controllers.js b/public/js/controllers.js index e49a2c4d..b148fada 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -59,9 +59,9 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { case "add": if(addNewNode(data)) - toastr['success']("New node connected!", "New node!"); + toastr['success']("New node "+ $scope.nodes[findIndex({id: data.id})].info.name +" connected!", "New node!"); else - toastr['info']("Node reconnected!", "Node is back!"); + toastr['info']("Node "+ $scope.nodes[findIndex({id: data.id})].info.name +" reconnected!", "Node is back!"); break; case "update": @@ -74,7 +74,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { case "inactive": $scope.nodes[findIndex({id: data.id})].stats = data.stats; - toastr['error']("Node went away!", "Node connection was lost!"); + toastr['error']("Node "+ $scope.nodes[findIndex({id: data.id})].info.name +" went away!", "Node connection was lost!"); break; } From 6c17d0ee9c8f85580fbcd061f5108ecb22d653fc Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 23 Feb 2015 15:57:41 +0200 Subject: [PATCH 04/13] added node latency --- app.js | 5 +++++ models/node.js | 1 + package.json | 1 + public/js/filters.js | 10 +++++++++- views/index.jade | 5 ++++- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 7a23383f..c23c7444 100644 --- a/app.js +++ b/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}); diff --git a/models/node.js b/models/node.js index beaa0f35..e327f7f7 100644 --- a/models/node.js +++ b/models/node.js @@ -21,6 +21,7 @@ var Node = function Node(data) }, blocktimeAvg: 0, difficulty: [], + latency: 0, uptime: 0, lastUpdate: 0 }; diff --git a/package.json b/package.json index eb56f0a1..a687b5a0 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/public/js/filters.js b/public/js/filters.js index 2ba0a9a2..0c78e012 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -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'; }; diff --git a/views/index.jade b/views/index.jade index cb818e36..4a6cca95 100644 --- a/views/index.jade +++ b/views/index.jade @@ -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}} From d4a2cba41fff6874449f4fdadb1018df2db31fca Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 23 Feb 2015 16:20:05 +0200 Subject: [PATCH 05/13] added latency on connection --- app.js | 1 + models/node.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app.js b/app.js index c23c7444..38d48e93 100644 --- a/app.js +++ b/app.js @@ -46,6 +46,7 @@ api.on('connection', function(spark) { { data.ip = spark.address.ip; data.spark = spark.id; + data.latency = spark.latency; var info = Nodes.add(data); spark.emit('ready'); diff --git a/models/node.js b/models/node.js index e327f7f7..114a3123 100644 --- a/models/node.js +++ b/models/node.js @@ -40,6 +40,9 @@ var Node = function Node(data) if(typeof data.spark !== 'undefined') this.spark = data.spark; + if(typeof data.latency !== 'undefined') + this.stats.latency = data.latency; + return this; } From f76e690f907664ae57b6d48d7c393dd9ba869380 Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 23 Feb 2015 16:48:00 +0200 Subject: [PATCH 06/13] refresh data --- models/node.js | 4 ++-- public/js/controllers.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/models/node.js b/models/node.js index 114a3123..f91afddc 100644 --- a/models/node.js +++ b/models/node.js @@ -16,10 +16,10 @@ var Node = function Node(data) difficulty: 0, number: 0, gasLimit: 0, - timestamp: 0, - blocktime: 0 + timestamp: 0 }, blocktimeAvg: 0, + blockTimes: [], difficulty: [], latency: 0, uptime: 0, diff --git a/public/js/controllers.js b/public/js/controllers.js index b148fada..2c048e85 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -18,6 +18,10 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { $scope.nodes = []; $scope.map = []; + $scope.timeout = setInterval(function(){ + $scope.$apply(); + }, 1000); + // Socket listeners // ---------------- From eb7186e9a4462e6bff402d1c38d518fa23961347 Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 23 Feb 2015 19:10:17 +0200 Subject: [PATCH 07/13] added propagation time --- models/node.js | 4 +++- views/index.jade | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/models/node.js b/models/node.js index f91afddc..5f58bd3f 100644 --- a/models/node.js +++ b/models/node.js @@ -16,7 +16,9 @@ var Node = function Node(data) difficulty: 0, number: 0, gasLimit: 0, - timestamp: 0 + timestamp: 0, + arrival: 0, + propagation: 0 }, blocktimeAvg: 0, blockTimes: [], diff --git a/views/index.jade b/views/index.jade index 4a6cca95..54e999ae 100644 --- a/views/index.jade +++ b/views/index.jade @@ -93,7 +93,9 @@ block content th i.icon-time(data-toggle="tooltip", data-placement="top", title="Last block time") th - i.icon-clock(data-toggle="tooltip", data-placement="top", title="Up-time") + i.icon-clock(data-toggle="tooltip", data-placement="top", title="Propagation time") + th + i.icon-bulb(data-toggle="tooltip", data-placement="top", title="Up-time") tbody tr(ng-repeat='node in nodes', class="{{ node.stats | mainClass : bestBlock }}") td(rel="{{node.id}}") @@ -113,4 +115,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}} 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.propagation}} ms td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }} From 146ac437b8b3fbd13415aacebc22508bc18b78b6 Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 24 Feb 2015 23:38:14 +0200 Subject: [PATCH 08/13] added more filters --- public/js/filters.js | 28 ++++++++++++++++++++++++++++ views/index.jade | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/public/js/filters.js b/public/js/filters.js index 0c78e012..8f60b3b1 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -78,6 +78,34 @@ angular.module('netStatsApp.filters', []) return timeClass(timestamp); }; }) +.filter('propagationTimeClass', function() { + return function(propagation) { + if(propagation <= 2000) + return 'text-success'; + + if(propagation <= 4000) + return 'text-info'; + + if(propagation <= 5000) + return 'text-warning'; + + return 'text-danger' + }; +}) +.filter('latencyClass', function() { + return function(time) { + if(time <= 1000) + return 'text-success'; + + if(time <= 2000) + return 'text-info'; + + if(time <= 3000) + return 'text-warning'; + + return 'text-danger' + }; +}) .filter('blockTimeFilter', function() { return function(timestamp) { if(timestamp === 0) diff --git a/views/index.jade b/views/index.jade index 54e999ae..95a9f7dd 100644 --- a/views/index.jade +++ b/views/index.jade @@ -104,7 +104,7 @@ 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.small(class="{{ node.stats.latency | latencyClass }}") {{node.stats | latencyFilter}} td(class="{{ node.stats.mining | miningClass }}") i.small(class="{{ node.stats.mining | miningIconClass }}") td(class="{{ node.stats.peers | peerClass }}", style="padding-left: 18px;") {{node.stats.peers}} @@ -115,5 +115,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}} 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.propagation}} ms + td(class="{{ node.stats.block.propagation | propagationTimeClass }}") {{node.stats.block.propagation}} ms td(class="{{ node.stats.uptime | upTimeClass }}") {{ node.stats.uptime | upTimeFilter }} From e2ccdac17e4196c9d9bc3b5025a4372062124286 Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 24 Feb 2015 23:43:02 +0200 Subject: [PATCH 09/13] filter optimisation --- public/js/filters.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/js/filters.js b/public/js/filters.js index 8f60b3b1..e11afb8c 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -80,13 +80,13 @@ angular.module('netStatsApp.filters', []) }) .filter('propagationTimeClass', function() { return function(propagation) { - if(propagation <= 2000) + if(propagation <= 3000) return 'text-success'; - if(propagation <= 4000) + if(propagation <= 7000) return 'text-info'; - if(propagation <= 5000) + if(propagation <= 10000) return 'text-warning'; return 'text-danger' @@ -94,13 +94,13 @@ angular.module('netStatsApp.filters', []) }) .filter('latencyClass', function() { return function(time) { - if(time <= 1000) + if(time <= 100) return 'text-success'; - if(time <= 2000) + if(time <= 1000) return 'text-info'; - if(time <= 3000) + if(time <= 2000) return 'text-warning'; return 'text-danger' From 9034ccdb5a0cd441131d005f9e6377e83df7698e Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 24 Feb 2015 23:24:12 +0100 Subject: [PATCH 10/13] ng-cloak display none --- public/css/style.css | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/css/style.css b/public/css/style.css index d7f2e52b..9400fa4c 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -122,4 +122,8 @@ table td i { .stat-holder { width: 100%; } -} \ No newline at end of file +} + +.ng-cloak { + display: none !important; +} From 4580336d6f5c886419f52d90aba04c448ee21e34 Mon Sep 17 00:00:00 2001 From: cubedro Date: Wed, 25 Feb 2015 00:39:47 +0200 Subject: [PATCH 11/13] more filter optimisation --- public/js/filters.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/public/js/filters.js b/public/js/filters.js index e11afb8c..796ca438 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -84,9 +84,6 @@ angular.module('netStatsApp.filters', []) return 'text-success'; if(propagation <= 7000) - return 'text-info'; - - if(propagation <= 10000) return 'text-warning'; return 'text-danger' @@ -98,9 +95,6 @@ angular.module('netStatsApp.filters', []) return 'text-success'; if(time <= 1000) - return 'text-info'; - - if(time <= 2000) return 'text-warning'; return 'text-danger' From 71a99d78680d46cafb41a111f01fb54ce2cfc3d1 Mon Sep 17 00:00:00 2001 From: cubedro Date: Wed, 25 Feb 2015 23:28:20 +0200 Subject: [PATCH 12/13] added travis.yml and badges --- .travis.yml | 3 +++ README.md | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..796d98f9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.12" diff --git a/README.md b/README.md index 706cdb49..1c49ab88 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -eth-netstats -============ - Ethereum Network Stats +============ +[![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] To run via Docker @@ -18,3 +17,8 @@ docker run --publish=3000:3000 eth-netstats ``` see the interface at http://localhost:3000 + +[travis-image]: https://travis-ci.org/cubedro/eth-netstats.svg +[travis-url]: https://travis-ci.org/cubedro/eth-netstats +[dep-image]: https://david-dm.org/cubedro/eth-netstats.svg +[dep-url]: https://david-dm.org/cubedro/eth-netstats \ No newline at end of file From 90d8845185acb648da83755a45b73a8a0bfdc0cb Mon Sep 17 00:00:00 2001 From: cubedro Date: Wed, 25 Feb 2015 23:34:09 +0200 Subject: [PATCH 13/13] updated npm packages versions --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a687b5a0..1e3fdf96 100644 --- a/package.json +++ b/package.json @@ -10,16 +10,16 @@ "start": "node ./bin/www" }, "dependencies": { - "body-parser": "~1.8.1", - "debug": "~2.0.0", + "body-parser": "1.12.0", + "debug": "2.1.1", "express": "^4.11.2", - "geoip-lite": "^1.1.4", - "jade": "~1.6.0", - "lodash": "^3.2.0", + "geoip-lite": "^1.1.5", + "jade": "^1.9.2", + "lodash": "^3.3.1", "primus": "^2.4.12", "primus-emit": "^0.1.2", "primus-spark-latency": "^0.1.1", - "serve-favicon": "~2.1.3", + "serve-favicon": "^2.2.0", "ws": "^0.7.1" } }