From 86e6bf11f8e3a686681e68d629a3db8d398e2f58 Mon Sep 17 00:00:00 2001 From: cubedro Date: Sun, 11 Dec 2016 18:06:25 +0200 Subject: [PATCH 1/4] added another trusted ip --- lib/utils/config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/utils/config.js b/lib/utils/config.js index 8e44668..bca9c16 100644 --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -16,6 +16,7 @@ var trusted = [ '185.37.145.18', '172.31.39.87', '86.120.171.69', + '86.123.155.6', '::ffff:127.0.0.1', ]; From a8920773f8d67a3ad52939d0d0f4c00bc284b10b Mon Sep 17 00:00:00 2001 From: cubedro Date: Sun, 11 Dec 2016 18:32:33 +0200 Subject: [PATCH 2/4] fixed canUpdateHistory --- lib/node.js | 3 +++ lib/utils/config.js | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/node.js b/lib/node.js index 66ce8af..8e4f9ca 100644 --- a/lib/node.js +++ b/lib/node.js @@ -374,6 +374,9 @@ Node.prototype.getBlockNumber = function() Node.prototype.canUpdate = function() { + if (this.trusted) { + return true; + } // return (this.info.canUpdateHistory && this.trusted) || false; return (this.info.canUpdateHistory || (this.stats.syncing === false && this.stats.peers > 0)) || false; } diff --git a/lib/utils/config.js b/lib/utils/config.js index bca9c16..8222c64 100644 --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -17,6 +17,7 @@ var trusted = [ '172.31.39.87', '86.120.171.69', '86.123.155.6', + '188.24.81.133', '::ffff:127.0.0.1', ]; From 1c1cb25d63bb9b5f7a3cd388c16e848e2cb6e9de Mon Sep 17 00:00:00 2001 From: cubedro Date: Sun, 11 Dec 2016 18:42:37 +0200 Subject: [PATCH 3/4] better history handling --- lib/collection.js | 4 ++-- lib/history.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/collection.js b/lib/collection.js index d3149f4..2297381 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -302,9 +302,9 @@ Collection.prototype.canNodeUpdate = function(id) if(node.canUpdate()) { - var diff = this._blockchain.bestBlockNumber() - node.getBlockNumber(); + var diff = node.getBlockNumber() - this._blockchain.bestBlockNumber(); - return (diff <= 0); + return Boolean(diff >= 0); } return false; diff --git a/lib/history.js b/lib/history.js index 8caa69f..182c8e2 100644 --- a/lib/history.js +++ b/lib/history.js @@ -634,7 +634,8 @@ History.prototype.getCharts = function() History.prototype.requiresUpdate = function() { - return ( this._items.length < MAX_HISTORY && !_.isEmpty(this._items) ); + // return ( this._items.length < MAX_HISTORY && !_.isEmpty(this._items) ); + return ( this._items.length < MAX_HISTORY ); } History.prototype.getHistoryRequestRange = function() From 941c17a201dc40c14ec471ac39d2776424f6666a Mon Sep 17 00:00:00 2001 From: cubedro Date: Sun, 11 Dec 2016 22:29:03 +0200 Subject: [PATCH 4/4] fixed buggy if --- lib/history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/history.js b/lib/history.js index 182c8e2..f71d61a 100644 --- a/lib/history.js +++ b/lib/history.js @@ -169,7 +169,7 @@ History.prototype.add = function(block, id, trusted, addingHistory) propagTimes: [] } - if( this._items.length === 0 || (this._items.length === MAX_HISTORY && block.number > this.worstBlockNumber() && !addingHistory) || (this._items.length < MAX_HISTORY && block.number < this.bestBlockNumber()) ) + if( this._items.length === 0 || (this._items.length === MAX_HISTORY && block.number > this.worstBlockNumber()) || (this._items.length < MAX_HISTORY && block.number < this.bestBlockNumber() && addingHistory) ) { item.propagTimes.push({ node: id,