diff --git a/models/node.js b/models/node.js index b6fcfd1..48aed48 100644 --- a/models/node.js +++ b/models/node.js @@ -37,6 +37,8 @@ var Node = function Node(data) history: [] }; + this.initBlockHistory(); + if(this.id === null) { this.uptime.started = (new Date()).getTime(); this.setState(true); @@ -89,6 +91,18 @@ Node.prototype.getInfo = function() return {id: this.id, info: this.info, geo: this.geo, stats: this.stats, history: this.blockHistory}; } +Node.prototype.initBlockHistory = function() +{ + for(var i=0; i < MAX_HISTORY; i++) + { + this.blockHistory.push({ + number: 0, + received: 0, + propagation: 0 + }); + } +} + Node.prototype.setStats = function(stats) { if(typeof stats !== 'undefined' && typeof stats.block !== 'undefined' && typeof stats.block.number !== 'undefined')