diff --git a/oracle/config/swap-tokens-worker.config.js b/oracle/config/swap-tokens-worker.config.js index bc34af89..9ef53d85 100644 --- a/oracle/config/swap-tokens-worker.config.js +++ b/oracle/config/swap-tokens-worker.config.js @@ -1,7 +1,15 @@ const baseConfig = require('./base.config') +const { EXIT_CODES } = require('../src/utils/constants') const id = `${baseConfig.id}-swap-tokens` +const workerRequired = baseConfig.id === 'erc-native' + +if (!workerRequired) { + console.error(`Swap tokens worker not required for bridge mode ${process.env.ORACLE_BRIDGE_MODE}`) + process.exit(EXIT_CODES.WATCHER_NOT_REQUIRED) +} + module.exports = { ...baseConfig.bridgeConfig, ...baseConfig.foreignConfig, diff --git a/oracle/src/watcher.js b/oracle/src/watcher.js index dea021d8..74309a99 100644 --- a/oracle/src/watcher.js +++ b/oracle/src/watcher.js @@ -148,14 +148,14 @@ async function main({ sendToQueue, sendToWorker }) { logger.info(`Found ${events.length} ${config.event} events`) if (events.length) { + if (sendToWorker) { + await sendToWorker({ blockNumber: toBlock.toString() }) + } + const job = await processEvents(events, toBlock) logger.info('Transactions to send:', job.length) if (job.length) { - if (sendToWorker) { - await sendToWorker({ blockNumber: toBlock.toString() }) - } - await sendToQueue(job) } }