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

pull/24/head
Peter Grassberger 5 years ago committed by Talha Cross
parent 0e52ac9ef0
commit 37dd25122a
  1. 11
      lib/history.js

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

Loading…
Cancel
Save