prevent crash due to missing adaptations to updated lodash lib, refs #1 (#19)

This commit is contained in:
Peter Grassberger 2019-12-11 11:48:47 +01:00 committed by Talha Cross
parent 0e52ac9ef0
commit 37dd25122a
1 changed files with 5 additions and 6 deletions

View File

@ -276,14 +276,14 @@ History.prototype.prevMaxBlock = function(number)
History.prototype.bestBlock = function()
{
return _.max(this._items, 'height');
return _.maxBy(this._items, 'height');
}
History.prototype.bestBlockNumber = function()
{
var best = this.bestBlock();
if( !_.isUndefined(best.height) )
if( !_.isUndefined(best) && !_.isUndefined(best.height) )
return best.height;
return 0;
@ -291,14 +291,14 @@ History.prototype.bestBlockNumber = function()
History.prototype.worstBlock = function()
{
return _.min(this._items, 'height');
return _.minBy(this._items, 'height');
}
History.prototype.worstBlockNumber = function(trusted)
{
var worst = this.worstBlock();
if( !_.isUndefined(worst.height) )
if( !_.isUndefined(worst) && !_.isUndefined(worst.height) )
return worst.height;
return 0;
@ -335,8 +335,7 @@ History.prototype.getNodePropagation = function(id)
}
}
})
.reverse()
.value();
.reverse();
return propagation;
}