mirror of
https://github.com/mempool/mempool.git
synced 2025-03-03 17:47:01 +01:00
Optionally support second CoreRPC instance as source for the minimum fee.
This commit is contained in:
parent
d49c347413
commit
eff4d2c8cd
3 changed files with 45 additions and 0 deletions
|
@ -22,6 +22,13 @@
|
||||||
"ESPLORA": {
|
"ESPLORA": {
|
||||||
"REST_API_URL": "http://127.0.0.1:3000"
|
"REST_API_URL": "http://127.0.0.1:3000"
|
||||||
},
|
},
|
||||||
|
"CORE_RPC_MINFEE": {
|
||||||
|
"ENABLED": false,
|
||||||
|
"HOST": "127.0.0.1",
|
||||||
|
"PORT": 8332,
|
||||||
|
"USERNAME": "mempool",
|
||||||
|
"PASSWORD": "mempool"
|
||||||
|
},
|
||||||
"DATABASE": {
|
"DATABASE": {
|
||||||
"ENABLED": true,
|
"ENABLED": true,
|
||||||
"HOST": "127.0.0.1",
|
"HOST": "127.0.0.1",
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { IBitcoinApi } from './bitcoin-api.interface';
|
||||||
|
|
||||||
class BitcoinBaseApi {
|
class BitcoinBaseApi {
|
||||||
bitcoindClient: any;
|
bitcoindClient: any;
|
||||||
|
bitcoindClientMempoolInfo: any;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.bitcoindClient = new bitcoin.Client({
|
this.bitcoindClient = new bitcoin.Client({
|
||||||
|
@ -13,9 +14,30 @@ class BitcoinBaseApi {
|
||||||
pass: config.CORE_RPC.PASSWORD,
|
pass: config.CORE_RPC.PASSWORD,
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (config.CORE_RPC_MINFEE.ENABLED) {
|
||||||
|
this.bitcoindClientMempoolInfo = new bitcoin.Client({
|
||||||
|
host: config.CORE_RPC_MINFEE.HOST,
|
||||||
|
port: config.CORE_RPC_MINFEE.PORT,
|
||||||
|
user: config.CORE_RPC_MINFEE.USERNAME,
|
||||||
|
pass: config.CORE_RPC_MINFEE.PASSWORD,
|
||||||
|
timeout: 60000,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$getMempoolInfo(): Promise<IBitcoinApi.MempoolInfo> {
|
$getMempoolInfo(): Promise<IBitcoinApi.MempoolInfo> {
|
||||||
|
if (config.CORE_RPC_MINFEE.ENABLED) {
|
||||||
|
return Promise.all([
|
||||||
|
this.bitcoindClient.getMempoolInfo(),
|
||||||
|
this.bitcoindClientMempoolInfo.getMempoolInfo()
|
||||||
|
]).then(([mempoolInfo, secondMempoolInfo]) => {
|
||||||
|
mempoolInfo.maxmempool = secondMempoolInfo.maxmempool;
|
||||||
|
mempoolInfo.mempoolminfee = secondMempoolInfo.mempoolminfee;
|
||||||
|
mempoolInfo.minrelaytxfee = secondMempoolInfo.minrelaytxfee;
|
||||||
|
return mempoolInfo;
|
||||||
|
});
|
||||||
|
}
|
||||||
return this.bitcoindClient.getMempoolInfo();
|
return this.bitcoindClient.getMempoolInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,13 @@ interface IConfig {
|
||||||
USERNAME: string;
|
USERNAME: string;
|
||||||
PASSWORD: string;
|
PASSWORD: string;
|
||||||
};
|
};
|
||||||
|
CORE_RPC_MINFEE: {
|
||||||
|
ENABLED: boolean;
|
||||||
|
HOST: string;
|
||||||
|
PORT: number;
|
||||||
|
USERNAME: string;
|
||||||
|
PASSWORD: string;
|
||||||
|
};
|
||||||
DATABASE: {
|
DATABASE: {
|
||||||
ENABLED: boolean;
|
ENABLED: boolean;
|
||||||
HOST: string,
|
HOST: string,
|
||||||
|
@ -77,6 +84,13 @@ const defaults: IConfig = {
|
||||||
'USERNAME': 'mempool',
|
'USERNAME': 'mempool',
|
||||||
'PASSWORD': 'mempool'
|
'PASSWORD': 'mempool'
|
||||||
},
|
},
|
||||||
|
'CORE_RPC_MINFEE': {
|
||||||
|
'ENABLED': false,
|
||||||
|
'HOST': '127.0.0.1',
|
||||||
|
'PORT': 8332,
|
||||||
|
'USERNAME': 'mempool',
|
||||||
|
'PASSWORD': 'mempool'
|
||||||
|
},
|
||||||
'DATABASE': {
|
'DATABASE': {
|
||||||
'ENABLED': true,
|
'ENABLED': true,
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
|
@ -111,6 +125,7 @@ class Config implements IConfig {
|
||||||
ESPLORA: IConfig['ESPLORA'];
|
ESPLORA: IConfig['ESPLORA'];
|
||||||
ELECTRUM: IConfig['ELECTRUM'];
|
ELECTRUM: IConfig['ELECTRUM'];
|
||||||
CORE_RPC: IConfig['CORE_RPC'];
|
CORE_RPC: IConfig['CORE_RPC'];
|
||||||
|
CORE_RPC_MINFEE: IConfig['CORE_RPC_MINFEE'];
|
||||||
DATABASE: IConfig['DATABASE'];
|
DATABASE: IConfig['DATABASE'];
|
||||||
STATISTICS: IConfig['STATISTICS'];
|
STATISTICS: IConfig['STATISTICS'];
|
||||||
BISQ_BLOCKS: IConfig['BISQ_BLOCKS'];
|
BISQ_BLOCKS: IConfig['BISQ_BLOCKS'];
|
||||||
|
@ -123,6 +138,7 @@ class Config implements IConfig {
|
||||||
this.ESPLORA = configs.ESPLORA;
|
this.ESPLORA = configs.ESPLORA;
|
||||||
this.ELECTRUM = configs.ELECTRUM;
|
this.ELECTRUM = configs.ELECTRUM;
|
||||||
this.CORE_RPC = configs.CORE_RPC;
|
this.CORE_RPC = configs.CORE_RPC;
|
||||||
|
this.CORE_RPC_MINFEE = configs.CORE_RPC_MINFEE;
|
||||||
this.DATABASE = configs.DATABASE;
|
this.DATABASE = configs.DATABASE;
|
||||||
this.STATISTICS = configs.STATISTICS;
|
this.STATISTICS = configs.STATISTICS;
|
||||||
this.BISQ_BLOCKS = configs.BISQ_BLOCKS;
|
this.BISQ_BLOCKS = configs.BISQ_BLOCKS;
|
||||||
|
|
Loading…
Add table
Reference in a new issue