From 4f08b3ae6f18b349b446e4876ccbe4defa4557b5 Mon Sep 17 00:00:00 2001 From: cubedro Date: Wed, 29 Apr 2015 02:10:23 +0300 Subject: [PATCH] fixed block add if lower than previous --- models/history.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/models/history.js b/models/history.js index 24cf539..278646f 100644 --- a/models/history.js +++ b/models/history.js @@ -33,7 +33,7 @@ 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' && typeof block.difficulty !== 'undefined' && (this._items.length === 0 || block.number >= (this.bestBlock().height - MAX_HISTORY + 1))) + if(typeof block !== 'undefined' && typeof block.number !== 'undefined' && typeof block.uncles !== 'undefined' && typeof block.transactions !== 'undefined' && typeof block.difficulty !== 'undefined') { var historyBlock = this.search(block.number); @@ -82,8 +82,11 @@ History.prototype.add = function(block, id) propagTimes: [] } - item.propagTimes.push({node: id, received: now, propagation: block.propagation}); - this._save(item); + if(this._items.length === 0 || block.number >= (this.bestBlock().height - MAX_HISTORY + 1)) + { + item.propagTimes.push({node: id, received: now, propagation: block.propagation}); + this._save(item); + } } return block;