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) {
|
||||
const maxDepth = tangle.maxDepth
|
||||
switch (goal.type) {
|
||||
case 'none':
|
||||
return EMPTY_RANGE
|
||||
case 'newest':
|
||||
const start = Math.max(0, maxDepth - goal.count + 1)
|
||||
return [start, maxDepth]
|
||||
|
||||
case 'all':
|
||||
case 'set':
|
||||
return [0, maxDepth]
|
||||
|
||||
case 'record':
|
||||
assertRecordPlugin(peer)
|
||||
const minDepth = peer.record.getMinRequiredDepth(goal.id)
|
||||
return [minDepth, maxDepth]
|
||||
case 'newest':
|
||||
const start = Math.max(0, maxDepth - goal.count + 1)
|
||||
return [start, maxDepth]
|
||||
|
||||
case 'none':
|
||||
return EMPTY_RANGE
|
||||
|
||||
default:
|
||||
throw new Error(`Unrecognized goal type: ${goal.type}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue