Merge pull request #343 from mempool/simon/clear-protection-config

Make clear protection timeout configurable.
This commit is contained in:
wiz 2021-02-15 00:26:47 +09:00 committed by GitHub
commit 033d1451d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -6,7 +6,8 @@
"SPAWN_CLUSTER_PROCS": 0, "SPAWN_CLUSTER_PROCS": 0,
"API_URL_PREFIX": "/api/v1/", "API_URL_PREFIX": "/api/v1/",
"POLL_RATE_MS": 2000, "POLL_RATE_MS": 2000,
"CACHE_DIR": "./cache" "CACHE_DIR": "./cache",
"CLEAR_PROTECTION_MINUTES": 20
}, },
"CORE_RPC": { "CORE_RPC": {
"HOST": "127.0.0.1", "HOST": "127.0.0.1",

View file

@ -10,7 +10,6 @@ import loadingIndicators from './loading-indicators';
class Mempool { class Mempool {
private static WEBSOCKET_REFRESH_RATE_MS = 10000; private static WEBSOCKET_REFRESH_RATE_MS = 10000;
private static CLEAR_PROTECTION_MINUTES = 10;
private inSync: boolean = false; private inSync: boolean = false;
private mempoolCache: { [txId: string]: TransactionExtended } = {}; private mempoolCache: { [txId: string]: TransactionExtended } = {};
private mempoolInfo: IBitcoinApi.MempoolInfo = { loaded: false, size: 0, bytes: 0, usage: 0, private mempoolInfo: IBitcoinApi.MempoolInfo = { loaded: false, size: 0, bytes: 0, usage: 0,
@ -143,7 +142,7 @@ class Mempool {
setTimeout(() => { setTimeout(() => {
this.mempoolProtection = 2; this.mempoolProtection = 2;
logger.warn('Mempool clear protection resumed.'); logger.warn('Mempool clear protection resumed.');
}, 1000 * 60 * Mempool.CLEAR_PROTECTION_MINUTES); }, 1000 * 60 * config.MEMPOOL.CLEAR_PROTECTION_MINUTES);
} }
let newMempool = {}; let newMempool = {};

View file

@ -9,6 +9,7 @@ interface IConfig {
API_URL_PREFIX: string; API_URL_PREFIX: string;
POLL_RATE_MS: number; POLL_RATE_MS: number;
CACHE_DIR: string; CACHE_DIR: string;
CLEAR_PROTECTION_MINUTES: number;
}; };
ESPLORA: { ESPLORA: {
REST_API_URL: string; REST_API_URL: string;
@ -61,7 +62,8 @@ const defaults: IConfig = {
'SPAWN_CLUSTER_PROCS': 0, 'SPAWN_CLUSTER_PROCS': 0,
'API_URL_PREFIX': '/api/v1/', 'API_URL_PREFIX': '/api/v1/',
'POLL_RATE_MS': 2000, 'POLL_RATE_MS': 2000,
'CACHE_DIR': './cache' 'CACHE_DIR': './cache',
'CLEAR_PROTECTION_MINUTES': 20,
}, },
'ESPLORA': { 'ESPLORA': {
'REST_API_URL': 'http://127.0.0.1:3000', 'REST_API_URL': 'http://127.0.0.1:3000',