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-02-20 17:12:22 +01:00
|
|
|
NETWORK: 'mainnet' | 'testnet' | 'signet' | 'liquid';
|
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;
|
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-01-15 16:23:32 +01:00
|
|
|
CORE_RPC_MINFEE: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
BISQ_BLOCKS: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
DATA_PATH: string;
|
|
|
|
};
|
|
|
|
BISQ_MARKETS: {
|
|
|
|
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,
|
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-01-15 16:23:32 +01:00
|
|
|
'CORE_RPC_MINFEE': {
|
|
|
|
'ENABLED': false,
|
|
|
|
'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
|
|
|
|
},
|
|
|
|
'BISQ_BLOCKS': {
|
|
|
|
'ENABLED': false,
|
|
|
|
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db/json'
|
|
|
|
},
|
|
|
|
'BISQ_MARKETS': {
|
|
|
|
'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-01-15 16:23:32 +01:00
|
|
|
CORE_RPC_MINFEE: IConfig['CORE_RPC_MINFEE'];
|
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'];
|
|
|
|
BISQ_BLOCKS: IConfig['BISQ_BLOCKS'];
|
|
|
|
BISQ_MARKETS: IConfig['BISQ_MARKETS'];
|
|
|
|
|
|
|
|
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-01-15 16:23:32 +01:00
|
|
|
this.CORE_RPC_MINFEE = configs.CORE_RPC_MINFEE;
|
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;
|
|
|
|
this.BISQ_BLOCKS = configs.BISQ_BLOCKS;
|
|
|
|
this.BISQ_MARKETS = configs.BISQ_MARKETS;
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|