From 37dd25122a11e139bafa9984cd8c5fb1cbe89aaf Mon Sep 17 00:00:00 2001 From: Peter Grassberger Date: Wed, 11 Dec 2019 11:48:47 +0100 Subject: [PATCH] prevent crash due to missing adaptations to updated lodash lib, refs #1 (#19) --- lib/history.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/history.js b/lib/history.js index b238271..a60123e 100644 --- a/lib/history.js +++ b/lib/history.js @@ -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; }