From f99d9061610f7b02b14ee1e001c090afe95047b9 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Wed, 25 Oct 2023 15:32:23 +0300 Subject: [PATCH] cosmetic refactor --- lib/index.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2034a3e..7f0bf6b 100644 --- a/lib/index.js +++ b/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}`) } }