better error handling
This commit is contained in:
parent
068133b021
commit
2fd2145d54
3
app.js
3
app.js
@ -82,6 +82,8 @@ api.on('connection', function(spark) {
|
||||
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){
|
||||
|
@ -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();
|
||||
@ -74,6 +76,9 @@ History.prototype.add = function(block, id)
|
||||
this.getNodePropagation(id);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
History.prototype._save = function(block)
|
||||
|
Loading…
Reference in New Issue
Block a user