Make bitcoin core timeout configurable
This commit is contained in:
		
							parent
							
								
									4d7ae1c8d5
								
							
						
					
					
						commit
						100daab4db
					
				@ -33,7 +33,8 @@
 | 
			
		||||
    "HOST": "127.0.0.1",
 | 
			
		||||
    "PORT": 8332,
 | 
			
		||||
    "USERNAME": "mempool",
 | 
			
		||||
    "PASSWORD": "mempool"
 | 
			
		||||
    "PASSWORD": "mempool",
 | 
			
		||||
    "TIMEOUT": 60000
 | 
			
		||||
  },
 | 
			
		||||
  "ELECTRUM": {
 | 
			
		||||
    "HOST": "127.0.0.1",
 | 
			
		||||
@ -47,7 +48,8 @@
 | 
			
		||||
    "HOST": "127.0.0.1",
 | 
			
		||||
    "PORT": 8332,
 | 
			
		||||
    "USERNAME": "mempool",
 | 
			
		||||
    "PASSWORD": "mempool"
 | 
			
		||||
    "PASSWORD": "mempool",
 | 
			
		||||
    "TIMEOUT": 60000
 | 
			
		||||
  },
 | 
			
		||||
  "DATABASE": {
 | 
			
		||||
    "ENABLED": true,
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,8 @@
 | 
			
		||||
    "HOST": "__CORE_RPC_HOST__",
 | 
			
		||||
    "PORT": 15,
 | 
			
		||||
    "USERNAME": "__CORE_RPC_USERNAME__",
 | 
			
		||||
    "PASSWORD": "__CORE_RPC_PASSWORD__"
 | 
			
		||||
    "PASSWORD": "__CORE_RPC_PASSWORD__",
 | 
			
		||||
    "TIMEOUT": "__CORE_RPC_TIMEOUT__"
 | 
			
		||||
  },
 | 
			
		||||
  "ELECTRUM": {
 | 
			
		||||
    "HOST": "__ELECTRUM_HOST__",
 | 
			
		||||
@ -48,7 +49,8 @@
 | 
			
		||||
    "HOST": "__SECOND_CORE_RPC_HOST__",
 | 
			
		||||
    "PORT": 17,
 | 
			
		||||
    "USERNAME": "__SECOND_CORE_RPC_USERNAME__",
 | 
			
		||||
    "PASSWORD": "__SECOND_CORE_RPC_PASSWORD__"
 | 
			
		||||
    "PASSWORD": "__SECOND_CORE_RPC_PASSWORD__",
 | 
			
		||||
    "TIMEOUT": "__SECOND_CORE_RPC_TIMEOUT__"
 | 
			
		||||
  },
 | 
			
		||||
  "DATABASE": {
 | 
			
		||||
    "ENABLED": false,
 | 
			
		||||
 | 
			
		||||
@ -52,14 +52,16 @@ describe('Mempool Backend Config', () => {
 | 
			
		||||
        HOST: '127.0.0.1',
 | 
			
		||||
        PORT: 8332,
 | 
			
		||||
        USERNAME: 'mempool',
 | 
			
		||||
        PASSWORD: 'mempool'
 | 
			
		||||
        PASSWORD: 'mempool',
 | 
			
		||||
        TIMEOUT: 60000
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      expect(config.SECOND_CORE_RPC).toStrictEqual({
 | 
			
		||||
        HOST: '127.0.0.1',
 | 
			
		||||
        PORT: 8332,
 | 
			
		||||
        USERNAME: 'mempool',
 | 
			
		||||
        PASSWORD: 'mempool'
 | 
			
		||||
        PASSWORD: 'mempool',
 | 
			
		||||
        TIMEOUT: 60000
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      expect(config.DATABASE).toStrictEqual({
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,7 @@ const nodeRpcCredentials: BitcoinRpcCredentials = {
 | 
			
		||||
  port: config.CORE_RPC.PORT,
 | 
			
		||||
  user: config.CORE_RPC.USERNAME,
 | 
			
		||||
  pass: config.CORE_RPC.PASSWORD,
 | 
			
		||||
  timeout: 60000,
 | 
			
		||||
  timeout: config.CORE_RPC.TIMEOUT,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default new bitcoin.Client(nodeRpcCredentials);
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,7 @@ const nodeRpcCredentials: BitcoinRpcCredentials = {
 | 
			
		||||
  port: config.SECOND_CORE_RPC.PORT,
 | 
			
		||||
  user: config.SECOND_CORE_RPC.USERNAME,
 | 
			
		||||
  pass: config.SECOND_CORE_RPC.PASSWORD,
 | 
			
		||||
  timeout: 60000,
 | 
			
		||||
  timeout: config.SECOND_CORE_RPC.TIMEOUT,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default new bitcoin.Client(nodeRpcCredentials);
 | 
			
		||||
 | 
			
		||||
@ -65,12 +65,14 @@ interface IConfig {
 | 
			
		||||
    PORT: number;
 | 
			
		||||
    USERNAME: string;
 | 
			
		||||
    PASSWORD: string;
 | 
			
		||||
    TIMEOUT: number;
 | 
			
		||||
  };
 | 
			
		||||
  SECOND_CORE_RPC: {
 | 
			
		||||
    HOST: string;
 | 
			
		||||
    PORT: number;
 | 
			
		||||
    USERNAME: string;
 | 
			
		||||
    PASSWORD: string;
 | 
			
		||||
    TIMEOUT: number;
 | 
			
		||||
  };
 | 
			
		||||
  DATABASE: {
 | 
			
		||||
    ENABLED: boolean;
 | 
			
		||||
@ -168,13 +170,15 @@ const defaults: IConfig = {
 | 
			
		||||
    'HOST': '127.0.0.1',
 | 
			
		||||
    'PORT': 8332,
 | 
			
		||||
    'USERNAME': 'mempool',
 | 
			
		||||
    'PASSWORD': 'mempool'
 | 
			
		||||
    'PASSWORD': 'mempool',
 | 
			
		||||
    'TIMEOUT': 60000,
 | 
			
		||||
  },
 | 
			
		||||
  'SECOND_CORE_RPC': {
 | 
			
		||||
    'HOST': '127.0.0.1',
 | 
			
		||||
    'PORT': 8332,
 | 
			
		||||
    'USERNAME': 'mempool',
 | 
			
		||||
    'PASSWORD': 'mempool'
 | 
			
		||||
    'PASSWORD': 'mempool',
 | 
			
		||||
    'TIMEOUT': 60000,
 | 
			
		||||
  },
 | 
			
		||||
  'DATABASE': {
 | 
			
		||||
    'ENABLED': true,
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,7 @@ If you want to use different credentials, specify them in the `docker-compose.ym
 | 
			
		||||
      CORE_RPC_PORT: "8332"
 | 
			
		||||
      CORE_RPC_USERNAME: "customuser"
 | 
			
		||||
      CORE_RPC_PASSWORD: "custompassword"
 | 
			
		||||
      CORE_RPC_TIMEOUT: "60000"
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
The IP address in the example above refers to Docker's default gateway IP address so that the container can hit the `bitcoind` instance running on the host machine. If your setup is different, update it accordingly.
 | 
			
		||||
@ -158,7 +159,8 @@ Corresponding `docker-compose.yml` overrides:
 | 
			
		||||
    "HOST": "127.0.0.1",
 | 
			
		||||
    "PORT": 8332,
 | 
			
		||||
    "USERNAME": "mempool",
 | 
			
		||||
    "PASSWORD": "mempool"
 | 
			
		||||
    "PASSWORD": "mempool",
 | 
			
		||||
    "TIMEOUT": 60000
 | 
			
		||||
  },
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@ -170,6 +172,7 @@ Corresponding `docker-compose.yml` overrides:
 | 
			
		||||
      CORE_RPC_PORT: ""
 | 
			
		||||
      CORE_RPC_USERNAME: ""
 | 
			
		||||
      CORE_RPC_PASSWORD: ""
 | 
			
		||||
      CORE_RPC_TIMEOUT: ""
 | 
			
		||||
      ...
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@ -219,7 +222,8 @@ Corresponding `docker-compose.yml` overrides:
 | 
			
		||||
    "HOST": "127.0.0.1",
 | 
			
		||||
    "PORT": 8332,
 | 
			
		||||
    "USERNAME": "mempool",
 | 
			
		||||
    "PASSWORD": "mempool"
 | 
			
		||||
    "PASSWORD": "mempool",
 | 
			
		||||
    "TIMEOUT": 60000
 | 
			
		||||
  },
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@ -231,6 +235,7 @@ Corresponding `docker-compose.yml` overrides:
 | 
			
		||||
      SECOND_CORE_RPC_PORT: ""
 | 
			
		||||
      SECOND_CORE_RPC_USERNAME: ""
 | 
			
		||||
      SECOND_CORE_RPC_PASSWORD: ""
 | 
			
		||||
      SECOND_CORE_RPC_TIMEOUT: ""
 | 
			
		||||
      ...
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,8 @@
 | 
			
		||||
    "HOST": "__CORE_RPC_HOST__",
 | 
			
		||||
    "PORT": __CORE_RPC_PORT__,
 | 
			
		||||
    "USERNAME": "__CORE_RPC_USERNAME__",
 | 
			
		||||
    "PASSWORD": "__CORE_RPC_PASSWORD__"
 | 
			
		||||
    "PASSWORD": "__CORE_RPC_PASSWORD__",
 | 
			
		||||
    "TIMEOUT": __CORE_RPC_TIMEOUT__
 | 
			
		||||
  },
 | 
			
		||||
  "ELECTRUM": {
 | 
			
		||||
    "HOST": "__ELECTRUM_HOST__",
 | 
			
		||||
@ -46,7 +47,8 @@
 | 
			
		||||
    "HOST": "__SECOND_CORE_RPC_HOST__",
 | 
			
		||||
    "PORT": __SECOND_CORE_RPC_PORT__,
 | 
			
		||||
    "USERNAME": "__SECOND_CORE_RPC_USERNAME__",
 | 
			
		||||
    "PASSWORD": "__SECOND_CORE_RPC_PASSWORD__"
 | 
			
		||||
    "PASSWORD": "__SECOND_CORE_RPC_PASSWORD__",
 | 
			
		||||
    "TIMEOUT": __SECOND_CORE_RPC_TIMEOUT__
 | 
			
		||||
  },
 | 
			
		||||
  "DATABASE": {
 | 
			
		||||
    "ENABLED": __DATABASE_ENABLED__,
 | 
			
		||||
 | 
			
		||||
@ -36,6 +36,7 @@ __CORE_RPC_HOST__=${CORE_RPC_HOST:=127.0.0.1}
 | 
			
		||||
__CORE_RPC_PORT__=${CORE_RPC_PORT:=8332}
 | 
			
		||||
__CORE_RPC_USERNAME__=${CORE_RPC_USERNAME:=mempool}
 | 
			
		||||
__CORE_RPC_PASSWORD__=${CORE_RPC_PASSWORD:=mempool}
 | 
			
		||||
__CORE_RPC_TIMEOUT__=${CORE_RPC_TIMEOUT:=60000}
 | 
			
		||||
 | 
			
		||||
# ELECTRUM
 | 
			
		||||
__ELECTRUM_HOST__=${ELECTRUM_HOST:=127.0.0.1}
 | 
			
		||||
@ -50,6 +51,7 @@ __SECOND_CORE_RPC_HOST__=${SECOND_CORE_RPC_HOST:=127.0.0.1}
 | 
			
		||||
__SECOND_CORE_RPC_PORT__=${SECOND_CORE_RPC_PORT:=8332}
 | 
			
		||||
__SECOND_CORE_RPC_USERNAME__=${SECOND_CORE_RPC_USERNAME:=mempool}
 | 
			
		||||
__SECOND_CORE_RPC_PASSWORD__=${SECOND_CORE_RPC_PASSWORD:=mempool}
 | 
			
		||||
__SECOND_CORE_RPC_TIMEOUT__=${SECOND_CORE_RPC_TIMEOUT:=60000}
 | 
			
		||||
 | 
			
		||||
# DATABASE
 | 
			
		||||
__DATABASE_ENABLED__=${DATABASE_ENABLED:=true}
 | 
			
		||||
@ -154,6 +156,7 @@ sed -i "s/__CORE_RPC_HOST__/${__CORE_RPC_HOST__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__CORE_RPC_PORT__/${__CORE_RPC_PORT__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__CORE_RPC_USERNAME__/${__CORE_RPC_USERNAME__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__CORE_RPC_PASSWORD__/${__CORE_RPC_PASSWORD__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__CORE_RPC_TIMEOUT__/${__CORE_RPC_TIMEOUT__}/g" mempool-config.json
 | 
			
		||||
 | 
			
		||||
sed -i "s/__ELECTRUM_HOST__/${__ELECTRUM_HOST__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__ELECTRUM_PORT__/${__ELECTRUM_PORT__}/g" mempool-config.json
 | 
			
		||||
@ -165,6 +168,7 @@ sed -i "s/__SECOND_CORE_RPC_HOST__/${__SECOND_CORE_RPC_HOST__}/g" mempool-config
 | 
			
		||||
sed -i "s/__SECOND_CORE_RPC_PORT__/${__SECOND_CORE_RPC_PORT__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__SECOND_CORE_RPC_USERNAME__/${__SECOND_CORE_RPC_USERNAME__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__SECOND_CORE_RPC_PASSWORD__/${__SECOND_CORE_RPC_PASSWORD__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__SECOND_CORE_RPC_TIMEOUT__/${__SECOND_CORE_RPC_TIMEOUT__}/g" mempool-config.json
 | 
			
		||||
 | 
			
		||||
sed -i "s/__DATABASE_ENABLED__/${__DATABASE_ENABLED__}/g" mempool-config.json
 | 
			
		||||
sed -i "s/__DATABASE_HOST__/${__DATABASE_HOST__}/g" mempool-config.json
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user