mirror of https://codeberg.org/pzp/pzp-goals.git
cosmetic refactor
This commit is contained in:
parent
ba364192ce
commit
f99d906161
16
lib/index.js
16
lib/index.js
|
@ -149,18 +149,24 @@ function initGoals(peer, config) {
|
||||||
function crossGoalWithTangle(goal, tangle) {
|
function crossGoalWithTangle(goal, tangle) {
|
||||||
const maxDepth = tangle.maxDepth
|
const maxDepth = tangle.maxDepth
|
||||||
switch (goal.type) {
|
switch (goal.type) {
|
||||||
case 'none':
|
case 'newest':
|
||||||
return EMPTY_RANGE
|
const start = Math.max(0, maxDepth - goal.count + 1)
|
||||||
|
return [start, maxDepth]
|
||||||
|
|
||||||
case 'all':
|
case 'all':
|
||||||
case 'set':
|
case 'set':
|
||||||
return [0, maxDepth]
|
return [0, maxDepth]
|
||||||
|
|
||||||
case 'record':
|
case 'record':
|
||||||
assertRecordPlugin(peer)
|
assertRecordPlugin(peer)
|
||||||
const minDepth = peer.record.getMinRequiredDepth(goal.id)
|
const minDepth = peer.record.getMinRequiredDepth(goal.id)
|
||||||
return [minDepth, maxDepth]
|
return [minDepth, maxDepth]
|
||||||
case 'newest':
|
|
||||||
const start = Math.max(0, maxDepth - goal.count + 1)
|
case 'none':
|
||||||
return [start, maxDepth]
|
return EMPTY_RANGE
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(`Unrecognized goal type: ${goal.type}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue