mirror of https://codeberg.org/pzp/pzp-goals.git
small refactor
This commit is contained in:
parent
f862c2de62
commit
46a8d8889c
15
lib/index.js
15
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue