diff --git a/backend/mempool-config.sample.json b/backend/mempool-config.sample.json index 1582929aa..bf0e15056 100644 --- a/backend/mempool-config.sample.json +++ b/backend/mempool-config.sample.json @@ -50,11 +50,7 @@ "ENABLED": true, "TX_PER_SECOND_SAMPLE_PERIOD": 150 }, - "BISQ_BLOCKS": { - "ENABLED": false, - "DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db/json" - }, - "BISQ_MARKETS": { + "BISQ": { "ENABLED": false, "DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db" } diff --git a/backend/src/api/bisq/bisq.ts b/backend/src/api/bisq/bisq.ts index cedb97faa..8d5cf83b7 100644 --- a/backend/src/api/bisq/bisq.ts +++ b/backend/src/api/bisq/bisq.ts @@ -8,7 +8,7 @@ import { StaticPool } from 'node-worker-threads-pool'; import logger from '../../logger'; class Bisq { - private static BLOCKS_JSON_FILE_PATH = config.BISQ_BLOCKS.DATA_PATH + '/all/blocks.json'; + private static BLOCKS_JSON_FILE_PATH = config.BISQ.DATA_PATH + '/json/all/blocks.json'; private latestBlockHeight = 0; private blocks: BisqBlock[] = []; private transactions: BisqTransaction[] = []; @@ -98,7 +98,7 @@ class Bisq { this.topDirectoryWatcher.close(); } let fsWait: NodeJS.Timeout | null = null; - this.topDirectoryWatcher = fs.watch(config.BISQ_BLOCKS.DATA_PATH, () => { + this.topDirectoryWatcher = fs.watch(config.BISQ.DATA_PATH + '/json', () => { if (fsWait) { clearTimeout(fsWait); } @@ -126,7 +126,7 @@ class Bisq { return; } let fsWait: NodeJS.Timeout | null = null; - this.subdirectoryWatcher = fs.watch(config.BISQ_BLOCKS.DATA_PATH + '/all', () => { + this.subdirectoryWatcher = fs.watch(config.BISQ.DATA_PATH + '/json/all', () => { if (fsWait) { clearTimeout(fsWait); } diff --git a/backend/src/api/bisq/markets.ts b/backend/src/api/bisq/markets.ts index 1d6169366..beac44851 100644 --- a/backend/src/api/bisq/markets.ts +++ b/backend/src/api/bisq/markets.ts @@ -6,7 +6,7 @@ import logger from '../../logger'; class Bisq { private static FOLDER_WATCH_CHANGE_DETECTION_DEBOUNCE = 4000; - private static MARKET_JSON_PATH = config.BISQ_MARKETS.DATA_PATH; + private static MARKET_JSON_PATH = config.BISQ.DATA_PATH; private static MARKET_JSON_FILE_PATHS = { activeCryptoCurrency: '/active_crypto_currency_list.json', activeFiatCurrency: '/active_fiat_currency_list.json', diff --git a/backend/src/config.ts b/backend/src/config.ts index d5828f922..4a2e4f588 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -52,11 +52,7 @@ interface IConfig { ENABLED: boolean; TX_PER_SECOND_SAMPLE_PERIOD: number; }; - BISQ_BLOCKS: { - ENABLED: boolean; - DATA_PATH: string; - }; - BISQ_MARKETS: { + BISQ: { ENABLED: boolean; DATA_PATH: string; }; @@ -114,11 +110,7 @@ const defaults: IConfig = { 'ENABLED': true, 'TX_PER_SECOND_SAMPLE_PERIOD': 150 }, - 'BISQ_BLOCKS': { - 'ENABLED': false, - 'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db/json' - }, - 'BISQ_MARKETS': { + 'BISQ': { 'ENABLED': false, 'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db' }, @@ -133,8 +125,7 @@ class Config implements IConfig { DATABASE: IConfig['DATABASE']; SYSLOG: IConfig['SYSLOG']; STATISTICS: IConfig['STATISTICS']; - BISQ_BLOCKS: IConfig['BISQ_BLOCKS']; - BISQ_MARKETS: IConfig['BISQ_MARKETS']; + BISQ: IConfig['BISQ']; constructor() { const configs = this.merge(configFile, defaults); @@ -146,8 +137,7 @@ class Config implements IConfig { this.DATABASE = configs.DATABASE; this.SYSLOG = configs.SYSLOG; this.STATISTICS = configs.STATISTICS; - this.BISQ_BLOCKS = configs.BISQ_BLOCKS; - this.BISQ_MARKETS = configs.BISQ_MARKETS; + this.BISQ = configs.BISQ; } merge = (...objects: object[]): IConfig => { diff --git a/backend/src/index.ts b/backend/src/index.ts index 54cf383d3..ec9c53cab 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -90,13 +90,10 @@ class Server { this.setUpHttpApiRoutes(); this.runMainUpdateLoop(); - if (config.BISQ_BLOCKS.ENABLED) { + if (config.BISQ.ENABLED) { bisq.startBisqService(); bisq.setPriceCallbackFunction((price) => websocketHandler.setExtraInitProperties('bsq-price', price)); blocks.setNewBlockCallback(bisq.handleNewBitcoinBlock.bind(bisq)); - } - - if (config.BISQ_MARKETS.ENABLED) { bisqMarkets.startBisqService(); } @@ -210,7 +207,7 @@ class Server { ; } - if (config.BISQ_BLOCKS.ENABLED) { + if (config.BISQ.ENABLED) { this.app .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/stats', routes.getBisqStats) .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/tx/:txId', routes.getBisqTransaction) @@ -219,11 +216,6 @@ class Server { .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/blocks/:index/:length', routes.getBisqBlocks) .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/address/:address', routes.getBisqAddress) .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/txs/:index/:length', routes.getBisqTransactions) - ; - } - - if (config.BISQ_MARKETS.ENABLED) { - this.app .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/currencies', routes.getBisqMarketCurrencies.bind(routes)) .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/depth', routes.getBisqMarketDepth.bind(routes)) .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/hloc', routes.getBisqMarketHloc.bind(routes)) diff --git a/backend/src/logger.ts b/backend/src/logger.ts index f14af0104..4e8c5ea11 100644 --- a/backend/src/logger.ts +++ b/backend/src/logger.ts @@ -73,7 +73,7 @@ class Logger { } private getNetwork(): string { - if (config.BISQ_BLOCKS.ENABLED) { + if (config.BISQ.ENABLED) { return 'bisq'; } if (config.MEMPOOL.NETWORK && config.MEMPOOL.NETWORK !== 'mainnet') { diff --git a/production/mempool-config.bisq.json b/production/mempool-config.bisq.json index 64ccc64bd..e58ef172c 100644 --- a/production/mempool-config.bisq.json +++ b/production/mempool-config.bisq.json @@ -27,11 +27,7 @@ "ENABLED": true, "TX_PER_SECOND_SAMPLE_PERIOD": 150 }, - "BISQ_BLOCKS": { - "ENABLED": true, - "DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db/json" - }, - "BISQ_MARKETS": { + "BISQ": { "ENABLED": true, "DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db" }