From f2d07c8cc7501be6ed03e46a758e745cfc1cf52a Mon Sep 17 00:00:00 2001 From: siiky Date: Mon, 23 Oct 2023 11:32:38 +0100 Subject: [PATCH] refactor: don't build `virtualRecyclers` in case of error --- lib/plugins.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/plugins.js b/lib/plugins.js index c81f8813..935a13a4 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -207,11 +207,8 @@ function plugins (settings, deviceId) { _.range(1, numberOfRecyclers+1) ) - const virtualRecyclers = denominations.length ? [Math.max(..._.flatten(denominations)) * 2] : [] - - if (counts.length !== denominations.length) { + if (counts.length !== denominations.length) throw new Error('Denominations and respective counts do not match!') - } const recyclers = _.map( it => ({ @@ -223,6 +220,8 @@ function plugins (settings, deviceId) { _.range(0, numberOfRecyclers) ) + const virtualRecyclers = denominations.length ? [Math.max(..._.flatten(denominations)) * 2] : [] + try { return { recyclers: computeAvailableRecyclers(recyclers, redeemableTxs),