From 925201c8f41a05dd7e44c63c45f444dbd854613b Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 7 Apr 2015 20:02:17 +0300 Subject: [PATCH] added initBlockHistory --- models/node.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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')