added peer propagation chart

This commit is contained in:
cubedro
2015-04-06 17:08:36 +03:00
parent 68e7f66f3d
commit 3493a5b2b1
5 changed files with 41 additions and 6 deletions

View File

@@ -1,5 +1,7 @@
var geoip = require('geoip-lite');
var MAX_HISTORY = 36;
var Node = function Node(data)
{
this.id = null;
@@ -29,6 +31,7 @@ var Node = function Node(data)
uptime: 0,
lastUpdate: 0
};
this.blockHistory = [];
this.uptime = {
started: null,
history: []
@@ -83,7 +86,7 @@ Node.prototype.setInfo = function(data)
Node.prototype.getInfo = function()
{
return {id: this.id, info: this.info, geo: this.geo, stats: this.stats};
return {id: this.id, info: this.info, geo: this.geo, stats: this.stats, history: this.blockHistory};
}
Node.prototype.setStats = function(stats)
@@ -92,6 +95,20 @@ Node.prototype.setStats = function(stats)
{
stats.block.hash = stats.block.hash.replace('0x', '');
if(stats.block.number > this.stats.block.number)
{
if(this.blockHistory.length === MAX_HISTORY )
this.blockHistory.shift();
var history = {
number: stats.block.number,
received: stats.block.received,
propagation: stats.block.propagation
};
this.blockHistory.push(history);
}
this.stats = stats;
return this.getStats();
@@ -114,7 +131,7 @@ Node.prototype.setLatency = function(latency)
Node.prototype.getStats = function()
{
return {id: this.id, stats: this.stats};
return {id: this.id, stats: this.stats, history: this.blockHistory};
}
Node.prototype.setState = function(active)