diff --git a/lib/index.js b/lib/index.js index fd7f9a8..d229d68 100644 --- a/lib/index.js +++ b/lib/index.js @@ -129,6 +129,16 @@ function initGoals(peer, config) { const watch = Obz() /** + * @param {Range} range + * @returns {boolean} + */ + function isEmptyRange(range) { + const [min, max] = range + return min > max + } + + /** + * Determine the range of msg depths that are goalful for this given tangle. * @private * @param {Goal} goal * @param {Tangle} tangle @@ -226,8 +236,9 @@ function initGoals(peer, config) { if (goal.type === 'none') break asRoot const tangle = peer.db.getTangle(msgID) if (!tangle) break asRoot - const [min, max] = crossGoalWithTangle(goal, tangle) - if (min > max) break asRoot + const range = crossGoalWithTangle(goal, tangle) + if (isEmptyRange(range)) break asRoot + const [min] = range if (min === 0) return ['goal'] if (min > 0) servesAsTrail = true }