2020-10-19 06:57:02 +02:00
|
|
|
const configFile = require('../mempool-config.json');
|
|
|
|
|
2020-10-19 13:36:29 +02:00
|
|
|
interface IConfig {
|
2020-10-19 06:57:02 +02:00
|
|
|
MEMPOOL: {
|
2021-12-28 14:59:11 +01:00
|
|
|
NETWORK: 'mainnet' | 'testnet' | 'signet' | 'liquid' | 'liquidtestnet';
|
2020-12-27 22:47:22 +01:00
|
|
|
BACKEND: 'esplora' | 'electrum' | 'none';
|
2020-10-19 06:57:02 +02:00
|
|
|
HTTP_PORT: number;
|
|
|
|
SPAWN_CLUSTER_PROCS: number;
|
|
|
|
API_URL_PREFIX: string;
|
2021-01-06 16:49:28 +01:00
|
|
|
POLL_RATE_MS: number;
|
2021-02-01 15:54:27 +01:00
|
|
|
CACHE_DIR: string;
|
2021-02-14 14:32:00 +01:00
|
|
|
CLEAR_PROTECTION_MINUTES: number;
|
2021-03-18 06:52:46 +01:00
|
|
|
RECOMMENDED_FEE_PERCENTILE: number;
|
2021-07-31 16:30:35 +02:00
|
|
|
BLOCK_WEIGHT_UNITS: number;
|
2021-07-31 16:56:10 +02:00
|
|
|
INITIAL_BLOCKS_AMOUNT: number;
|
|
|
|
MEMPOOL_BLOCKS_AMOUNT: number;
|
2021-08-29 21:30:11 +02:00
|
|
|
PRICE_FEED_UPDATE_INTERVAL: number;
|
2021-09-19 00:40:16 +02:00
|
|
|
USE_SECOND_NODE_FOR_MINFEE: boolean;
|
2021-12-20 23:00:50 +01:00
|
|
|
EXTERNAL_ASSETS: string[];
|
2020-10-19 06:57:02 +02:00
|
|
|
};
|
2021-01-06 16:49:28 +01:00
|
|
|
ESPLORA: {
|
2020-10-19 06:57:02 +02:00
|
|
|
REST_API_URL: string;
|
2021-01-04 21:06:57 +01:00
|
|
|
};
|
|
|
|
ELECTRUM: {
|
2020-12-20 16:36:36 +01:00
|
|
|
HOST: string;
|
|
|
|
PORT: number;
|
2021-01-06 16:49:28 +01:00
|
|
|
TLS_ENABLED: boolean;
|
2020-10-19 06:57:02 +02:00
|
|
|
};
|
2021-01-11 08:53:18 +01:00
|
|
|
CORE_RPC: {
|
2020-12-20 16:36:36 +01:00
|
|
|
HOST: string;
|
|
|
|
PORT: number;
|
|
|
|
USERNAME: string;
|
|
|
|
PASSWORD: string;
|
2020-12-27 22:47:22 +01:00
|
|
|
};
|
2021-09-14 23:47:24 +02:00
|
|
|
SECOND_CORE_RPC: {
|
2021-01-15 16:23:32 +01:00
|
|
|
HOST: string;
|
|
|
|
PORT: number;
|
|
|
|
USERNAME: string;
|
|
|
|
PASSWORD: string;
|
|
|
|
};
|
2020-10-19 06:57:02 +02:00
|
|
|
DATABASE: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
HOST: string,
|
|
|
|
PORT: number;
|
|
|
|
DATABASE: string;
|
|
|
|
USERNAME: string;
|
|
|
|
PASSWORD: string;
|
|
|
|
};
|
2021-04-15 14:04:09 +02:00
|
|
|
SYSLOG: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
HOST: string;
|
|
|
|
PORT: number;
|
|
|
|
MIN_PRIORITY: 'emerg' | 'alert' | 'crit' | 'err' |'warn' | 'notice' | 'info' | 'debug';
|
|
|
|
FACILITY: string;
|
|
|
|
};
|
2020-10-19 06:57:02 +02:00
|
|
|
STATISTICS: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
TX_PER_SECOND_SAMPLE_PERIOD: number;
|
|
|
|
};
|
2021-04-25 00:38:46 +02:00
|
|
|
BISQ: {
|
2020-10-19 06:57:02 +02:00
|
|
|
ENABLED: boolean;
|
|
|
|
DATA_PATH: string;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-19 13:36:29 +02:00
|
|
|
const defaults: IConfig = {
|
|
|
|
'MEMPOOL': {
|
|
|
|
'NETWORK': 'mainnet',
|
2020-12-27 22:47:22 +01:00
|
|
|
'BACKEND': 'none',
|
2020-10-19 13:36:29 +02:00
|
|
|
'HTTP_PORT': 8999,
|
|
|
|
'SPAWN_CLUSTER_PROCS': 0,
|
|
|
|
'API_URL_PREFIX': '/api/v1/',
|
2021-02-01 15:54:27 +01:00
|
|
|
'POLL_RATE_MS': 2000,
|
2021-02-14 14:32:00 +01:00
|
|
|
'CACHE_DIR': './cache',
|
|
|
|
'CLEAR_PROTECTION_MINUTES': 20,
|
2021-03-18 06:52:46 +01:00
|
|
|
'RECOMMENDED_FEE_PERCENTILE': 50,
|
2021-07-31 16:30:35 +02:00
|
|
|
'BLOCK_WEIGHT_UNITS': 4000000,
|
2021-07-31 16:56:10 +02:00
|
|
|
'INITIAL_BLOCKS_AMOUNT': 8,
|
|
|
|
'MEMPOOL_BLOCKS_AMOUNT': 8,
|
2021-08-29 21:30:11 +02:00
|
|
|
'PRICE_FEED_UPDATE_INTERVAL': 3600,
|
2021-09-19 00:40:16 +02:00
|
|
|
'USE_SECOND_NODE_FOR_MINFEE': false,
|
2021-12-20 23:00:50 +01:00
|
|
|
'EXTERNAL_ASSETS': [],
|
2020-10-19 13:36:29 +02:00
|
|
|
},
|
2021-01-06 16:49:28 +01:00
|
|
|
'ESPLORA': {
|
2020-10-19 13:36:29 +02:00
|
|
|
'REST_API_URL': 'http://127.0.0.1:3000',
|
2021-01-04 21:06:57 +01:00
|
|
|
},
|
|
|
|
'ELECTRUM': {
|
2020-12-20 16:36:36 +01:00
|
|
|
'HOST': '127.0.0.1',
|
2021-01-04 21:06:57 +01:00
|
|
|
'PORT': 3306,
|
2021-01-06 16:49:28 +01:00
|
|
|
'TLS_ENABLED': true,
|
2020-12-20 16:36:36 +01:00
|
|
|
},
|
2021-01-11 08:53:18 +01:00
|
|
|
'CORE_RPC': {
|
2020-12-27 22:47:22 +01:00
|
|
|
'HOST': '127.0.0.1',
|
2020-12-20 16:36:36 +01:00
|
|
|
'PORT': 8332,
|
2020-12-27 22:47:22 +01:00
|
|
|
'USERNAME': 'mempool',
|
|
|
|
'PASSWORD': 'mempool'
|
2020-10-19 13:36:29 +02:00
|
|
|
},
|
2021-09-14 23:47:24 +02:00
|
|
|
'SECOND_CORE_RPC': {
|
2021-01-15 16:23:32 +01:00
|
|
|
'HOST': '127.0.0.1',
|
|
|
|
'PORT': 8332,
|
|
|
|
'USERNAME': 'mempool',
|
|
|
|
'PASSWORD': 'mempool'
|
|
|
|
},
|
2020-10-19 13:36:29 +02:00
|
|
|
'DATABASE': {
|
|
|
|
'ENABLED': true,
|
2021-01-30 12:43:58 +01:00
|
|
|
'HOST': '127.0.0.1',
|
2020-10-19 13:36:29 +02:00
|
|
|
'PORT': 3306,
|
|
|
|
'DATABASE': 'mempool',
|
|
|
|
'USERNAME': 'mempool',
|
|
|
|
'PASSWORD': 'mempool'
|
|
|
|
},
|
2021-04-15 14:04:09 +02:00
|
|
|
'SYSLOG': {
|
|
|
|
'ENABLED': true,
|
|
|
|
'HOST': '127.0.0.1',
|
|
|
|
'PORT': 514,
|
|
|
|
'MIN_PRIORITY': 'info',
|
|
|
|
'FACILITY': 'local7'
|
|
|
|
},
|
2020-10-19 13:36:29 +02:00
|
|
|
'STATISTICS': {
|
|
|
|
'ENABLED': true,
|
|
|
|
'TX_PER_SECOND_SAMPLE_PERIOD': 150
|
|
|
|
},
|
2021-04-25 00:38:46 +02:00
|
|
|
'BISQ': {
|
2020-10-19 13:36:29 +02:00
|
|
|
'ENABLED': false,
|
|
|
|
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db'
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-10-19 06:57:02 +02:00
|
|
|
class Config implements IConfig {
|
|
|
|
MEMPOOL: IConfig['MEMPOOL'];
|
2021-01-06 16:49:28 +01:00
|
|
|
ESPLORA: IConfig['ESPLORA'];
|
2021-01-04 21:06:57 +01:00
|
|
|
ELECTRUM: IConfig['ELECTRUM'];
|
2021-01-11 08:53:18 +01:00
|
|
|
CORE_RPC: IConfig['CORE_RPC'];
|
2021-09-14 23:47:24 +02:00
|
|
|
SECOND_CORE_RPC: IConfig['SECOND_CORE_RPC'];
|
2020-10-19 06:57:02 +02:00
|
|
|
DATABASE: IConfig['DATABASE'];
|
2021-04-15 14:04:09 +02:00
|
|
|
SYSLOG: IConfig['SYSLOG'];
|
2020-10-19 06:57:02 +02:00
|
|
|
STATISTICS: IConfig['STATISTICS'];
|
2021-04-25 00:38:46 +02:00
|
|
|
BISQ: IConfig['BISQ'];
|
2020-10-19 06:57:02 +02:00
|
|
|
|
|
|
|
constructor() {
|
2020-10-19 13:36:29 +02:00
|
|
|
const configs = this.merge(configFile, defaults);
|
|
|
|
this.MEMPOOL = configs.MEMPOOL;
|
2021-01-06 16:49:28 +01:00
|
|
|
this.ESPLORA = configs.ESPLORA;
|
2021-01-04 21:06:57 +01:00
|
|
|
this.ELECTRUM = configs.ELECTRUM;
|
2021-01-11 08:53:18 +01:00
|
|
|
this.CORE_RPC = configs.CORE_RPC;
|
2021-09-14 23:47:24 +02:00
|
|
|
this.SECOND_CORE_RPC = configs.SECOND_CORE_RPC;
|
2020-10-19 13:36:29 +02:00
|
|
|
this.DATABASE = configs.DATABASE;
|
2021-04-15 14:04:09 +02:00
|
|
|
this.SYSLOG = configs.SYSLOG;
|
2020-10-19 13:36:29 +02:00
|
|
|
this.STATISTICS = configs.STATISTICS;
|
2021-04-25 00:38:46 +02:00
|
|
|
this.BISQ = configs.BISQ;
|
2020-10-19 13:36:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
merge = (...objects: object[]): IConfig => {
|
|
|
|
// @ts-ignore
|
|
|
|
return objects.reduce((prev, next) => {
|
|
|
|
Object.keys(prev).forEach(key => {
|
|
|
|
next[key] = { ...next[key], ...prev[key] };
|
|
|
|
});
|
|
|
|
return next;
|
|
|
|
});
|
2020-10-19 06:57:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default new Config();
|