Merge pull request #102 from cubedro/develop
Better error handling and logging
This commit is contained in:
commit
0fda04414b
13
app.js
13
app.js
@ -43,7 +43,7 @@ api.on('connection', function(spark) {
|
||||
spark.on('hello', function(data)
|
||||
{
|
||||
console.log('Latency: ', spark.latency);
|
||||
console.log('got hello data from ', spark.id);
|
||||
console.log('Got hello data from ', spark.id);
|
||||
console.log(data);
|
||||
|
||||
if(typeof data.secret === 'undefined' || data.secret !== WS_SECRET)
|
||||
@ -75,13 +75,15 @@ api.on('connection', function(spark) {
|
||||
spark.on('update', function(data)
|
||||
{
|
||||
console.log('Latency: ', spark.latency);
|
||||
console.log('got update from ' + spark.id);
|
||||
console.log('Got update from ' + spark.id);
|
||||
|
||||
if(typeof data.id !== 'undefined' && typeof data.stats !== 'undefined')
|
||||
{
|
||||
data.stats.latency = spark.latency;
|
||||
|
||||
var stats = Nodes.update(data.id, data.stats);
|
||||
if(stats !== false)
|
||||
{
|
||||
client.write({action: 'update', data: stats});
|
||||
|
||||
var blockPropagationChart = Nodes.blockPropagationChart();
|
||||
@ -90,6 +92,7 @@ api.on('connection', function(spark) {
|
||||
var uncleCount = Nodes.getUncleCount();
|
||||
client.write({action: 'uncleCount', data: uncleCount});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
spark.on('node-ping', function(data){
|
||||
@ -98,9 +101,6 @@ api.on('connection', function(spark) {
|
||||
|
||||
spark.on('latency', function(data)
|
||||
{
|
||||
console.log('Latency: ', data.latency);
|
||||
console.log('got ping from ' + spark.id);
|
||||
|
||||
if(typeof data.id !== 'undefined')
|
||||
{
|
||||
var stats = Nodes.updateLatency(data.id, data.latency);
|
||||
@ -123,9 +123,6 @@ client.on('connection', function(spark) {
|
||||
console.log(spark.query);
|
||||
|
||||
spark.on('ready', function(data){
|
||||
console.log('got hello data from ' + spark.id);
|
||||
console.log(data);
|
||||
|
||||
spark.emit('init', {nodes: Nodes.all()});
|
||||
|
||||
var blockPropagationChart = Nodes.blockPropagationChart();
|
||||
|
@ -27,6 +27,10 @@ Collection.prototype.update = function(id, stats)
|
||||
return false;
|
||||
|
||||
var block = this._history.add(stats.block, id);
|
||||
|
||||
if(! block)
|
||||
return false;
|
||||
|
||||
var propagationHistory = this._history.getNodePropagation(id);
|
||||
|
||||
stats.block.arrived = block.arrived;
|
||||
|
@ -33,6 +33,8 @@ var History = function History(data)
|
||||
|
||||
History.prototype.add = function(block, id)
|
||||
{
|
||||
if(typeof block !== 'undefined' && typeof block.number !== 'undefined' && typeof block.uncles !== 'undefined' && typeof block.transactions !== 'undefined')
|
||||
{
|
||||
var historyBlock = this.search(block.number);
|
||||
|
||||
var now = (new Date()).getTime();
|
||||
@ -68,12 +70,14 @@ History.prototype.add = function(block, id)
|
||||
}
|
||||
|
||||
item.propagTimes.push({node: id, received: now, propagation: block.propagation});
|
||||
console.log('item: ', item);
|
||||
this._save(item);
|
||||
}
|
||||
this.getNodePropagation(id);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
History.prototype._save = function(block)
|
||||
@ -170,7 +174,29 @@ History.prototype.getUncleCount = function(id)
|
||||
})
|
||||
.value();
|
||||
|
||||
console.log(uncles);
|
||||
var uncleBins = _.fill(Array(MAX_BINS), 0);
|
||||
|
||||
var sumMapper = function(array, key) {
|
||||
uncleBins[key] = _.sum(array);
|
||||
return _.sum(array);
|
||||
};
|
||||
|
||||
_.map(_.chunk(uncles, MAX_UNCLES_PER_BIN), sumMapper);
|
||||
|
||||
return uncleBins;
|
||||
}
|
||||
|
||||
History.prototype.getTransactionsCount = function(id)
|
||||
{
|
||||
var uncles = _(this._items)
|
||||
.sortByOrder('height', false)
|
||||
.slice(0, MAX_BINS - 1)
|
||||
.reverse()
|
||||
.map(function(item)
|
||||
{
|
||||
return item.block.transactions.length;
|
||||
})
|
||||
.value();
|
||||
|
||||
var uncleBins = _.fill(Array(MAX_BINS), 0);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "eth-netstats",
|
||||
"description": "Ethereum Network Intelligence dashboard",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": "0.12.0",
|
||||
|
Loading…
Reference in New Issue
Block a user