diff --git a/backend/mempool-config.sample.json b/backend/mempool-config.sample.json index 312d9d18d..e636c9e2d 100644 --- a/backend/mempool-config.sample.json +++ b/backend/mempool-config.sample.json @@ -21,7 +21,9 @@ "EXTERNAL_RETRY_INTERVAL": 0, "USER_AGENT": "mempool", "STDOUT_LOG_MIN_PRIORITY": "debug", - "AUTOMATIC_BLOCK_REINDEXING": false + "AUTOMATIC_BLOCK_REINDEXING": false, + "POOLS_JSON_URL": "https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json", + "POOLS_JSON_TREE_URL": "https://api.github.com/repos/mempool/mining-pools/git/trees/master" }, "CORE_RPC": { "HOST": "127.0.0.1", diff --git a/backend/src/config.ts b/backend/src/config.ts index ddf1fd3d4..6f6301a65 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -24,6 +24,8 @@ interface IConfig { USER_AGENT: string; STDOUT_LOG_MIN_PRIORITY: 'emerg' | 'alert' | 'crit' | 'err' | 'warn' | 'notice' | 'info' | 'debug'; AUTOMATIC_BLOCK_REINDEXING: boolean; + POOLS_JSON_URL: string, + POOLS_JSON_TREE_URL: string, }; ESPLORA: { REST_API_URL: string; @@ -136,6 +138,8 @@ const defaults: IConfig = { 'USER_AGENT': 'mempool', 'STDOUT_LOG_MIN_PRIORITY': 'debug', 'AUTOMATIC_BLOCK_REINDEXING': false, + 'POOLS_JSON_URL': 'https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json', + 'POOLS_JSON_TREE_URL': 'https://api.github.com/repos/mempool/mining-pools/git/trees/master', }, 'ESPLORA': { 'REST_API_URL': 'http://127.0.0.1:3000', diff --git a/backend/src/tasks/pools-updater.ts b/backend/src/tasks/pools-updater.ts index 04d9d5d07..11bb8060f 100644 --- a/backend/src/tasks/pools-updater.ts +++ b/backend/src/tasks/pools-updater.ts @@ -12,14 +12,11 @@ import * as https from 'https'; */ class PoolsUpdater { lastRun: number = 0; - currentSha: any = undefined; - poolsUrl: string = 'https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json'; - treeUrl: string = 'https://api.github.com/repos/mempool/mining-pools/git/trees/master'; + currentSha: string | undefined = undefined; + poolsUrl: string = config.MEMPOOL.POOLS_JSON_URL; + treeUrl: string = config.MEMPOOL.POOLS_JSON_TREE_URL; - constructor() { - } - - public async updatePoolsJson() { + public async updatePoolsJson(): Promise { if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) { return; } @@ -77,7 +74,7 @@ class PoolsUpdater { /** * Fetch our latest pools.json sha from the db */ - private async updateDBSha(githubSha: string) { + private async updateDBSha(githubSha: string): Promise { this.currentSha = githubSha; if (config.DATABASE.ENABLED === true) { try { diff --git a/docker/README.md b/docker/README.md index 14b80c19e..dd42462a7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -102,7 +102,9 @@ Below we list all settings from `mempool-config.json` and the corresponding over "PRICE_FEED_UPDATE_INTERVAL": 600, "USE_SECOND_NODE_FOR_MINFEE": false, "EXTERNAL_ASSETS": ["https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json"], - "STDOUT_LOG_MIN_PRIORITY": "info" + "STDOUT_LOG_MIN_PRIORITY": "info", + "POOLS_JSON_URL": "https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json", + "POOLS_JSON_TREE_URL": "https://api.github.com/repos/mempool/mining-pools/git/trees/master" }, ``` @@ -126,6 +128,8 @@ Corresponding `docker-compose.yml` overrides: MEMPOOL_USE_SECOND_NODE_FOR_MINFEE: "" MEMPOOL_EXTERNAL_ASSETS: "" MEMPOOL_STDOUT_LOG_MIN_PRIORITY: "" + MEMPOOL_POOLS_JSON_URL: "" + MEMPOOL_POOLS_JSON_TREE_URL: "" ... ``` diff --git a/docker/backend/start.sh b/docker/backend/start.sh index c31273bb6..3d754c979 100644 --- a/docker/backend/start.sh +++ b/docker/backend/start.sh @@ -24,6 +24,8 @@ __MEMPOOL_USER_AGENT__=${MEMPOOL_USER_AGENT:=mempool} __MEMPOOL_STDOUT_LOG_MIN_PRIORITY__=${MEMPOOL_STDOUT_LOG_MIN_PRIORITY:=info} __MEMPOOL_INDEXING_BLOCKS_AMOUNT__=${MEMPOOL_INDEXING_BLOCKS_AMOUNT:=false} __MEMPOOL_AUTOMATIC_BLOCK_REINDEXING__=${MEMPOOL_AUTOMATIC_BLOCK_REINDEXING:=false} +__MEMPOOL_POOLS_JSON_URL__=${MEMPOOL_POOLS_JSON_URL:=false} +__MEMPOOL_POOLS_JSON_TREE_URL__=${MEMPOOL_POOLS_JSON_TREE_URL:=false} # CORE_RPC __CORE_RPC_HOST__=${CORE_RPC_HOST:=127.0.0.1} @@ -114,6 +116,8 @@ sed -i "s!__MEMPOOL_USER_AGENT__!${__MEMPOOL_USER_AGENT__}!g" mempool-config.jso sed -i "s/__MEMPOOL_STDOUT_LOG_MIN_PRIORITY__/${__MEMPOOL_STDOUT_LOG_MIN_PRIORITY__}/g" mempool-config.json sed -i "s/__MEMPOOL_INDEXING_BLOCKS_AMOUNT__/${__MEMPOOL_INDEXING_BLOCKS_AMOUNT__}/g" mempool-config.json sed -i "s/__MEMPOOL_AUTOMATIC_BLOCK_REINDEXING__/${__MEMPOOL_AUTOMATIC_BLOCK_REINDEXING__}/g" mempool-config.json +sed -i "s/__MEMPOOL_POOLS_JSON_URL__/${__MEMPOOL_POOLS_JSON_URL__}/g" mempool-config.json +sed -i "s/__MEMPOOL_POOLS_JSON_TREE_URL__/${__MEMPOOL_POOLS_JSON_TREE_URL__}/g" mempool-config.json 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