From ed2de112a23e806d32f7e64e4034f6fb87ecfaed Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Thu, 28 Nov 2019 16:56:18 -0300 Subject: [PATCH] fixes --- oracle/config/swap-tokens-worker.config.js | 8 ++++++++ oracle/src/watcher.js | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) 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) } }