cosmetic refactor

This commit is contained in:
Andre Staltz 2023-10-25 15:32:23 +03:00
parent ba364192ce
commit f99d906161
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 11 additions and 5 deletions

View File

@ -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}`)
}
}