New backend config "NETWORK".

Only activate mempool protection.
Log network to
fixes #140
This commit is contained in:
softsimon 2020-10-15 11:07:53 +07:00
parent 372c116283
commit 86c654f22f
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
4 changed files with 8 additions and 5 deletions

View File

@ -8,7 +8,7 @@
"DB_DISABLED": false,
"API_ENDPOINT": "/api/v1/",
"ELECTRS_POLL_RATE_MS": 2000,
"LIQUID": true,
"NETWORK": "mainnet",
"MEMPOOL_REFRESH_RATE_MS": 2000,
"DEFAULT_PROJECTED_BLOCKS_AMOUNT": 8,
"KEEP_BLOCK_AMOUNT": 24,

View File

@ -5,7 +5,7 @@ import projectedBlocks from './mempool-blocks';
class FeeApi {
constructor() { }
defaultFee = config.LIQUID ? 0.1 : 1;
defaultFee = config.NETWORK === 'liquid' ? 0.1 : 1;
public getRecommendedFee() {
const pBlocks = projectedBlocks.getMempoolBlocks();

View File

@ -135,7 +135,8 @@ class Mempool {
}
// Prevent mempool from clear on bitcoind restart by delaying the deletion
if (this.mempoolProtection === 0 && transactions.length / currentMempoolSize <= 0.80) {
if ((config.NETWORK === 'mainnet' || !config.NETWORK)
&& this.mempoolProtection === 0 && transactions.length / currentMempoolSize <= 0.80) {
this.mempoolProtection = 1;
this.inSync = false;
logger.warn(`Mempool clear protection triggered because transactions.length: ${transactions.length} and currentMempoolSize: ${currentMempoolSize}.`);

View File

@ -1,3 +1,4 @@
const config = require('../mempool-config.json');
import * as dgram from 'dgram';
class Logger {
@ -82,9 +83,10 @@ class Logger {
msg = msg.slice(0, msg.length - 1);
}
}
const network = (config.NETWORK === 'mainnet' || !config.NETWORK) ? '' : ' <' + config.NETWORK + '>';
prionum = Logger.priorities[priority] || Logger.priorities.info;
syslogmsg = `<${(this.fac * 8 + prionum)}> ${this.name}[${process.pid}]: ${priority.toUpperCase()} ${msg}`;
consolemsg = `${this.ts()} [${process.pid}] ${priority.toUpperCase()}: ${msg}`;
syslogmsg = `<${(this.fac * 8 + prionum)}> ${this.name}[${process.pid}]: ${priority.toUpperCase()}${network} ${msg}`;
consolemsg = `${this.ts()} [${process.pid}] ${priority.toUpperCase()}:${network} ${msg}`;
this.syslog(syslogmsg);
if (priority === 'warning') {