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..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, @@ -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() 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 8e44668..8222c64 100644 --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -16,6 +16,8 @@ var trusted = [ '185.37.145.18', '172.31.39.87', '86.120.171.69', + '86.123.155.6', + '188.24.81.133', '::ffff:127.0.0.1', ];