Unified Bisq config

This commit is contained in:
softsimon 2021-04-25 02:38:46 +04:00
parent c1fc08196b
commit 5878a2e631
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
7 changed files with 13 additions and 39 deletions

View File

@ -50,11 +50,7 @@
"ENABLED": true, "ENABLED": true,
"TX_PER_SECOND_SAMPLE_PERIOD": 150 "TX_PER_SECOND_SAMPLE_PERIOD": 150
}, },
"BISQ_BLOCKS": { "BISQ": {
"ENABLED": false,
"DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db/json"
},
"BISQ_MARKETS": {
"ENABLED": false, "ENABLED": false,
"DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db" "DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db"
} }

View File

@ -8,7 +8,7 @@ import { StaticPool } from 'node-worker-threads-pool';
import logger from '../../logger'; import logger from '../../logger';
class Bisq { 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 latestBlockHeight = 0;
private blocks: BisqBlock[] = []; private blocks: BisqBlock[] = [];
private transactions: BisqTransaction[] = []; private transactions: BisqTransaction[] = [];
@ -98,7 +98,7 @@ class Bisq {
this.topDirectoryWatcher.close(); this.topDirectoryWatcher.close();
} }
let fsWait: NodeJS.Timeout | null = null; 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) { if (fsWait) {
clearTimeout(fsWait); clearTimeout(fsWait);
} }
@ -126,7 +126,7 @@ class Bisq {
return; return;
} }
let fsWait: NodeJS.Timeout | null = null; 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) { if (fsWait) {
clearTimeout(fsWait); clearTimeout(fsWait);
} }

View File

@ -6,7 +6,7 @@ import logger from '../../logger';
class Bisq { class Bisq {
private static FOLDER_WATCH_CHANGE_DETECTION_DEBOUNCE = 4000; 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 = { private static MARKET_JSON_FILE_PATHS = {
activeCryptoCurrency: '/active_crypto_currency_list.json', activeCryptoCurrency: '/active_crypto_currency_list.json',
activeFiatCurrency: '/active_fiat_currency_list.json', activeFiatCurrency: '/active_fiat_currency_list.json',

View File

@ -52,11 +52,7 @@ interface IConfig {
ENABLED: boolean; ENABLED: boolean;
TX_PER_SECOND_SAMPLE_PERIOD: number; TX_PER_SECOND_SAMPLE_PERIOD: number;
}; };
BISQ_BLOCKS: { BISQ: {
ENABLED: boolean;
DATA_PATH: string;
};
BISQ_MARKETS: {
ENABLED: boolean; ENABLED: boolean;
DATA_PATH: string; DATA_PATH: string;
}; };
@ -114,11 +110,7 @@ const defaults: IConfig = {
'ENABLED': true, 'ENABLED': true,
'TX_PER_SECOND_SAMPLE_PERIOD': 150 'TX_PER_SECOND_SAMPLE_PERIOD': 150
}, },
'BISQ_BLOCKS': { 'BISQ': {
'ENABLED': false,
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db/json'
},
'BISQ_MARKETS': {
'ENABLED': false, 'ENABLED': false,
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db' 'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db'
}, },
@ -133,8 +125,7 @@ class Config implements IConfig {
DATABASE: IConfig['DATABASE']; DATABASE: IConfig['DATABASE'];
SYSLOG: IConfig['SYSLOG']; SYSLOG: IConfig['SYSLOG'];
STATISTICS: IConfig['STATISTICS']; STATISTICS: IConfig['STATISTICS'];
BISQ_BLOCKS: IConfig['BISQ_BLOCKS']; BISQ: IConfig['BISQ'];
BISQ_MARKETS: IConfig['BISQ_MARKETS'];
constructor() { constructor() {
const configs = this.merge(configFile, defaults); const configs = this.merge(configFile, defaults);
@ -146,8 +137,7 @@ class Config implements IConfig {
this.DATABASE = configs.DATABASE; this.DATABASE = configs.DATABASE;
this.SYSLOG = configs.SYSLOG; this.SYSLOG = configs.SYSLOG;
this.STATISTICS = configs.STATISTICS; this.STATISTICS = configs.STATISTICS;
this.BISQ_BLOCKS = configs.BISQ_BLOCKS; this.BISQ = configs.BISQ;
this.BISQ_MARKETS = configs.BISQ_MARKETS;
} }
merge = (...objects: object[]): IConfig => { merge = (...objects: object[]): IConfig => {

View File

@ -90,13 +90,10 @@ class Server {
this.setUpHttpApiRoutes(); this.setUpHttpApiRoutes();
this.runMainUpdateLoop(); this.runMainUpdateLoop();
if (config.BISQ_BLOCKS.ENABLED) { if (config.BISQ.ENABLED) {
bisq.startBisqService(); bisq.startBisqService();
bisq.setPriceCallbackFunction((price) => websocketHandler.setExtraInitProperties('bsq-price', price)); bisq.setPriceCallbackFunction((price) => websocketHandler.setExtraInitProperties('bsq-price', price));
blocks.setNewBlockCallback(bisq.handleNewBitcoinBlock.bind(bisq)); blocks.setNewBlockCallback(bisq.handleNewBitcoinBlock.bind(bisq));
}
if (config.BISQ_MARKETS.ENABLED) {
bisqMarkets.startBisqService(); bisqMarkets.startBisqService();
} }
@ -210,7 +207,7 @@ class Server {
; ;
} }
if (config.BISQ_BLOCKS.ENABLED) { if (config.BISQ.ENABLED) {
this.app this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/stats', routes.getBisqStats) .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/stats', routes.getBisqStats)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/tx/:txId', routes.getBisqTransaction) .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/blocks/:index/:length', routes.getBisqBlocks)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/address/:address', routes.getBisqAddress) .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/address/:address', routes.getBisqAddress)
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/txs/:index/:length', routes.getBisqTransactions) .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/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/depth', routes.getBisqMarketDepth.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/hloc', routes.getBisqMarketHloc.bind(routes)) .get(config.MEMPOOL.API_URL_PREFIX + 'bisq/markets/hloc', routes.getBisqMarketHloc.bind(routes))

View File

@ -73,7 +73,7 @@ class Logger {
} }
private getNetwork(): string { private getNetwork(): string {
if (config.BISQ_BLOCKS.ENABLED) { if (config.BISQ.ENABLED) {
return 'bisq'; return 'bisq';
} }
if (config.MEMPOOL.NETWORK && config.MEMPOOL.NETWORK !== 'mainnet') { if (config.MEMPOOL.NETWORK && config.MEMPOOL.NETWORK !== 'mainnet') {

View File

@ -27,11 +27,7 @@
"ENABLED": true, "ENABLED": true,
"TX_PER_SECOND_SAMPLE_PERIOD": 150 "TX_PER_SECOND_SAMPLE_PERIOD": 150
}, },
"BISQ_BLOCKS": { "BISQ": {
"ENABLED": true,
"DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db/json"
},
"BISQ_MARKETS": {
"ENABLED": true, "ENABLED": true,
"DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db" "DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db"
} }