Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
- add support for registered and elected validators
Browse files Browse the repository at this point in the history
- fix graphs: block time, gas spending, gas limit
  • Loading branch information
diminator committed Oct 28, 2019
1 parent 2d0d4c3 commit 81c5f6c
Show file tree
Hide file tree
Showing 11 changed files with 586 additions and 649 deletions.
16 changes: 15 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ module.exports = function(grunt) {
js: ['dist/js/*.*', '!dist/js/netstats.*'],
css: ['dist/css/*.css', '!dist/css/netstats.*.css']
},
watch: {
css: {
files: ['src/css/*.css'],
tasks: ['default']
},
js: {
files: ['src/js/*.js'],
tasks: ['default']
},
html: {
files: ['src/views/*.jade'],
tasks: ['default']
}
},
jade: {
build: {
options: {
Expand Down Expand Up @@ -189,6 +203,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['clean:build', 'clean:js', 'clean:css', 'jade:build', 'copy:build', 'cssmin:build', 'concat:vendor', 'concat:scripts', 'uglify:app', 'concat:netstats', 'concat:css', 'clean:js', 'clean:css']);
};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ grunt --configPath="src/js/someOtherConfig.js"
Start a node process and pass a trusted node to it or edit the list of trusted nodes in [the server config](/lib/utils/config.js).

```bash
TRUSTED_NODE=node://39a8f532a242c29bdeeeb... npm start
TRUSTED_NODE=enode://39a8f532a242c29bdeeeb... npm start
```
Find the interface at http://localhost:3000
29 changes: 12 additions & 17 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ api.on('connection', function (spark) {
|| reserved.indexOf(stats.id) >= 0
|| _.isUndefined(proof)
|| _.isUndefined(proof.publicKey)
|| trusted.indexOf(`node://${proof.publicKey.substr(4)}`) < 0
|| trusted.indexOf(`enode://${proof.publicKey.substr(4)}`) < 0
|| !authorize(proof, stats)) {
spark.end(undefined, { reconnect: false });
console.error('API', 'CON', 'Closed - wrong auth', data);
Expand Down Expand Up @@ -253,17 +253,17 @@ api.on('connection', function (spark) {

var time = chalk.reset.cyan((new Date()).toJSON()) + " ";
console.time(time, 'COL', 'CHR', 'Got charts in');
Nodes.addHistory(stats.id, stats.history, function (err, history) {
console.timeEnd(time, 'COL', 'CHR', 'Got charts in');
if (err !== null) {
console.error('COL', 'CHR', 'History error:', err);
} else {
client.write({
action: 'charts',
data: history
});
}
});
// Nodes.addHistory(stats.id, stats.history, function (err, history) {
// console.timeEnd(time, 'COL', 'CHR', 'Got charts in');
// if (err !== null) {
// console.error('COL', 'CHR', 'History error:', err);
// } else {
// client.write({
// action: 'charts',
// data: history
// });
// }
// });
}
});

Expand Down Expand Up @@ -293,11 +293,6 @@ api.on('connection', function (spark) {
}

if (latency !== null) {
// client.write({
// action: 'latency',
// data: latency
// });

console.success('API', 'PIN', 'Latency:', latency, 'from:', stats.id);
}
});
Expand Down
10 changes: 5 additions & 5 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ Collection.prototype.addBlock = function (id, stats, callback) {
stats.arrived = block.block.arrived;
stats.received = block.block.received;
stats.propagation = block.block.propagation;

stats.validators = block.block.validators;

if (block.block.number > this._highestBlock) {
this._highestBlock = block.block.number;
this._externalAPI.write({
Expand Down Expand Up @@ -116,9 +117,8 @@ Collection.prototype.addHistory = function (id, blocks, callback) {
// this._blockchain.clean(this.getBestBlockFromItems());

for (var i = 0; i <= blocks.length - 1; i++) {
this._blockchain.add(blocks[i], id, node.trusted, true);
this._blockchain.add(blocks[i], id, true, true);
}
;

this.getCharts();
}
Expand Down Expand Up @@ -220,9 +220,9 @@ Collection.prototype.getChartsDebounced = function () {
if (this._debounced === null) {
this._debounced = _.debounce(function () {
self._blockchain.getCharts();
}, 1000, {
}, 500, {
leading: false,
maxWait: 5000,
maxWait: 2000,
trailing: true
});
}
Expand Down
22 changes: 10 additions & 12 deletions lib/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,9 @@ History.prototype.search = function (number) {
}

History.prototype.prevMaxBlock = function (number) {
var index = _.findIndex(this._items, function (item) {
return item.height < number;
});

const heights = this._items.map(item=>item.height)
const index = heights.indexOf(Math.max(...heights))

if (index < 0)
return false;

Expand Down Expand Up @@ -515,12 +514,8 @@ History.prototype.getCharts = function () {
if (this._callback !== null) {
var chartHistory = _(this._items)
.sortBy('height', false)
// .filter(function (item)
// {
// return item.block.trusted;
// })
.slice(0, MAX_BINS)
.reverse()
.slice(0, MAX_BINS)
.map(function (item) {
return {
height: item.height,
Expand All @@ -534,17 +529,20 @@ History.prototype.getCharts = function () {
};
})
.value();
const padArray = function(arr,len,fill) {
return arr.concat(Array(len).fill(fill)).slice(0,len);
}

this._callback(null, {
height: _.map(chartHistory, 'height'),
blocktime: _.map(chartHistory, 'blocktime'),
blocktime: padArray(_.map(chartHistory, 'blocktime'), MAX_BINS, 0),
// avgBlocktime : _.sum(_.map( chartHistory, 'blocktime' )) / (chartHistory.length === 0 ? 1 : chartHistory.length),
avgBlocktime: this.getAvgBlocktime(),
difficulty: _.map(chartHistory, 'difficulty'),
uncles: _.map(chartHistory, 'uncles'),
transactions: _.map(chartHistory, 'transactions'),
gasSpending: _.map(chartHistory, 'gasSpending'),
gasLimit: _.map(chartHistory, 'gasLimit'),
gasSpending: padArray(_.map(chartHistory, 'gasSpending'), MAX_BINS, 0),
gasLimit: padArray(_.map(chartHistory, 'gasLimit'), MAX_BINS, 0),
miners: this.getMinersCount(),
propagation: this.getBlockPropagation(),
uncleCount: this.getUncleCount(),
Expand Down
2 changes: 1 addition & 1 deletion lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Node.prototype.setInfo = function (data, callback) {
if (trusted.indexOf(data.ip) >= 0 || process.env.LITE === 'true') {
this.trusted = true;
}

this.trusted = true;
this.setGeo(data.ip);
}

Expand Down
26 changes: 25 additions & 1 deletion lib/utils/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
var trusted = [];
var trusted = [
"enode://31fd9c7fbca58626f5aade18109a0a37b2add3cfc198a0c2101456a0a3af347e7c19f7f3ef632d636044068bf3a27ecf1ba80ddeb6b61bb961a6170e87a3a985",
"enode://00640a61bef8eb09fe293f90437f0f78dfdff19d4fc69fb29074f1e56a068e6948d9159a7f7aec1f5532158558f98538b688acc44d68767caf9909ca1669cd0d",
"enode://44f631d76bf32b8e7a6ebfd2b457c1a647c3cc4fe58c19ff229ef4fa39f74eef2eed6ad22b7a6cb9ab510ff9dd85678aebd39c22c98487fd99502cc228abb873",
"enode://92926eaf538f6d5be75bec5c591b944b2965adaaa3e9b2a97a7f6c3ad8422db8276cfd82c90fffa2993f2c0bc91ff8e67392c30658f67330bf1537f37bd2ef3f",
"enode://9c2d0a13b2c932b535872a6dd5376a6eb1e9c5f901df34918251059982bb8b28a3f4f226794c83a0f5f8f07303a0b40fe1768ddaa4ede7a6d7880f8aa6223e5a",
'enode://9c2d0a13b2c932b535872a6dd5376a6eb1e9c5f901df34918251059982bb8b28a3f4f226794c83a0f5f8f07303a0b40fe1768ddaa4ede7a6d7880f8aa6223e5a',
'enode://801324197c05050081697b5490034febb14d302515d3b2e7f08b572363a229ed266243b37f7f8aef8ce07502e4b26224100a41d5b15bc35c97f74d1be56f2272',
'enode://b96ae0186603e6e7f977710309db18e2b4def26c908581aa6fa6f3b5ac26c7431a6251cbe21e026b6bff6f432cd26800c7ada2b947103bf45295ba8827f2c9f3',
'enode://af5795085411e9eaf508b5e21d75e6349d86d79d35502d4f5bc12d7002319cdb7d47dc4f9b9a55382f25778bfa0f40f4dd712e85684b94ba67ecbed2ca770a1b',
'enode://4275da1d6af647ea4f13ac776910347ed74c91625b1e5c1e8c920a060e0f5350d735b78962765ba581b634be6000aeb3b2b3085a7dbd69614b76e5e6108a7263',
'enode://44d1591e3de2ce64844d7824e262c8e41060e7f3e22fd9735f95541ad90afb81be7f549fc5ac0da549896f61b56463ddecf3e2c4cfe3602a6d25285a800059cb',
'enode://23817f449c723c14b52a2c9ce5e0daf5efc26461a9fe02e8dad6c04327afcad3320690c73549f7c90b27657a49f62f463895f94a220064b23b5b87333d8b31a9',
'enode://8b603327c27a95c600b6162e1375425a420cbb323b2e7f794109656ed1a42aaf5c3a00fee3af7aa9022c51ead4fb1580177e47f2699ecdf81dccbecee01d5d18',
'enode://5f92befc72ea546735d2116f9cc7222ddedd2adc9e7d6c3c833ed62e460359789607013fd286d97741eb90c1bf3913d89b215446049ba8cc30fe65c41c0514fc',
'enode://d5958ffd337d53b4522d9e5be214a56503648a1246b10801e8a5272c1c6eb59c10f286322b7e700f25fa030b68dd65bae6ead93a56cf34f4b38474b12fdd93a5',
'enode://6867a105247d59eb3c6c9b14608e4123be6d2bf0c76a08123a5c7a7b5f6faa5277e212e54b6e0197403e8fcbf496a3096864a87466869a3bd8d19471e8eb05a6',
'enode://8692370256cefcbca1e5ef454eb74c990dfa37d9fdada1cea3fa168fb6521dd25c25ab2f265b25651481f311e9de38d95a299617c4d181d556faa10f6f68a1e9',
'enode://4dae4723c20a242dda71188d730f334a87ed6813542a19cdceb277cdc4e7cbdb52957e493cbf60264a26f7957fc396d09f92d3bae9a32764e44082b7ad4fd8bc',
'enode://8de031c313ae8e7baaa16dab0a1a0b6dca61a5197f5aca2de6a64a7d1830fccb6c22b236ebbc211aef035bed434fd4b9f2411bfecd1629bf83b85dfdc5a886a2',
'enode://0d90889654382b6495ae0c1be16303719589855c8098a82a64e9360959c5957e25c9e02e1bb81df9e90ce3113653b2de576f69297613dc7d49c25cb82d30d56b',
'enode://2d0b30475c94cda63c359c8da17a546b05a1cc06a4c554590f25c08e6b423899b41b299e9ecb7704c2b4b0be8fec3d38909d5479cc5a002dd39e7d0866219f73',
'enode://e715cb22af21bb1871ed5ab1009a65913c14ca0d6752d45e009e12e27944d184efe8b8aba7d4bbf9f5ef835cedd67727c4138277e6168e5b9ab040e5d7dc80af',
'enode://87b18575160ce6406e9971de44a694d2cc850d0f6b4d1f51f4560e1da3a84d04046994a92fab3a23a708b87e8c780823b89c93e3b1a2caad873a607d04258f0c'
]

var banned = [];

Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
"geoip-lite": "^1.3.5",
"grunt": "^1.0.3",
"grunt-cli": "^1.3.2",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^3.0.0",
"grunt-contrib-jade": "^1.0.0",
"grunt-contrib-uglify": "^4.0.0",
"jade": "^1.11.0",
"lodash": "4.17.11",
"primus": "^7.3.1",
Expand Down Expand Up @@ -56,5 +50,13 @@
}
],
"license": "LGPL-3.0",
"devDependencies": {}
"devDependencies": {
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^3.0.0",
"grunt-contrib-jade": "^1.0.0",
"grunt-contrib-uglify": "^4.0.0",
"grunt-contrib-watch": "^1.1.0"
}
}
32 changes: 23 additions & 9 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ body {
font-smooth: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: #2E3338;
}

@font-face {
Expand All @@ -19,7 +20,7 @@ body {

@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-style: normal;
font-weight: 300;
src: local('Source Sans Pro Light'), local('SourceSansPro-Light'), url(../fonts/SourceSansPro-Light.woff2) format('woff2');
}
Expand Down Expand Up @@ -52,6 +53,10 @@ table td {
-moz-osx-font-smoothing: auto;
}

table tr {
border: 1px solid rgba(255,255,255, 0.1);
}

.propagationBox {
position: relative;
width: 8px;
Expand All @@ -65,12 +70,18 @@ table td {

.bg-success,
.text-success .propagationBox {
background: #50fa7b;
background: #35D07F;
}
.text-success{
color:#35D07F
}

.bg-info,
.text-info .propagationBox {
background: #8be9fd;
background: #73DDFF;
}
.text-info {
color: #73DDFF;
}

.bg-highlight,
Expand All @@ -80,7 +91,7 @@ table td {

.bg-warning,
.text-warning .propagationBox {
background: #f1fa8c;
background: #FFB765;
}

.bg-orange,
Expand All @@ -103,7 +114,7 @@ table td {
.bg-warning,
.bg-orange,
.bg-danger {
color: #000;
color: #2E3338;
}

.text-gray {
Expand All @@ -120,8 +131,8 @@ table td {
}

.stat-holder {
background: #090909;
border: 1px solid rgba(255,255,255,0.05);
background: #2E3338;
border: 1px solid rgba(255,255,255, 0.1);
}

.big-info {
Expand Down Expand Up @@ -151,7 +162,7 @@ div.small-title-miner {
line-height: 20px;
letter-spacing: 1px;
text-transform: uppercase;
color: #aaa;
/* color: #aaa; */
}

span.small-title span.small {
Expand Down Expand Up @@ -297,7 +308,7 @@ table i {

table th,
table td {
border-color: #222 !important;
border-color: rgba(255,255,255, 0.1) !important;
}

table td {
Expand Down Expand Up @@ -556,3 +567,6 @@ svg .y.axis .tick:first-child text {
font-size: 10px;
}
}


.table-striped>tbody>tr:nth-child(odd){background-color:#2E3338}
Loading

0 comments on commit 81c5f6c

Please sign in to comment.