This commit is contained in:
Jonathan Brown 2017-04-10 16:57:29 +07:00
commit 4ca0f384f1
4 changed files with 10 additions and 4 deletions

View File

@ -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;

View File

@ -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()

View File

@ -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;
}

View File

@ -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',
];