diff --git a/backend/mempool-config.sample.json b/backend/mempool-config.sample.json index b0b157c42..6de690ad8 100644 --- a/backend/mempool-config.sample.json +++ b/backend/mempool-config.sample.json @@ -25,7 +25,8 @@ "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", - "ADVANCED_TRANSACTION_SELECTION": false, + "ADVANCED_GBT_AUDIT": false, + "ADVANCED_GBT_MEMPOOL": false, "TRANSACTION_INDEXING": false }, "CORE_RPC": { diff --git a/backend/src/__fixtures__/mempool-config.template.json b/backend/src/__fixtures__/mempool-config.template.json index 8b368a43a..7a988a70d 100644 --- a/backend/src/__fixtures__/mempool-config.template.json +++ b/backend/src/__fixtures__/mempool-config.template.json @@ -26,7 +26,8 @@ "INDEXING_BLOCKS_AMOUNT": 14, "POOLS_JSON_TREE_URL": "__POOLS_JSON_TREE_URL__", "POOLS_JSON_URL": "__POOLS_JSON_URL__", - "ADVANCED_TRANSACTION_SELECTION": "__ADVANCED_TRANSACTION_SELECTION__", + "ADVANCED_GBT_AUDIT": "__ADVANCED_GBT_AUDIT__", + "ADVANCED_GBT_MEMPOOL": "__ADVANCED_GBT_MEMPOOL__", "TRANSACTION_INDEXING": "__TRANSACTION_INDEXING__" }, "CORE_RPC": { diff --git a/backend/src/__tests__/config.test.ts b/backend/src/__tests__/config.test.ts index c95888cf2..58cf3a214 100644 --- a/backend/src/__tests__/config.test.ts +++ b/backend/src/__tests__/config.test.ts @@ -38,7 +38,8 @@ describe('Mempool Backend Config', () => { STDOUT_LOG_MIN_PRIORITY: 'debug', POOLS_JSON_TREE_URL: 'https://api.github.com/repos/mempool/mining-pools/git/trees/master', POOLS_JSON_URL: 'https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json', - ADVANCED_TRANSACTION_SELECTION: false, + ADVANCED_GBT_AUDIT: false, + ADVANCED_GBT_MEMPOOL: false, TRANSACTION_INDEXING: false, }); diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index 0499fe842..31224fc0c 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -250,12 +250,12 @@ class WebsocketHandler { throw new Error('WebSocket.Server is not set'); } - if (config.MEMPOOL.ADVANCED_TRANSACTION_SELECTION) { + if (config.MEMPOOL.ADVANCED_GBT_MEMPOOL) { await mempoolBlocks.makeBlockTemplates(newMempool, 8, null, true); - } - else { + } else { mempoolBlocks.updateMempoolBlocks(newMempool); } + const mBlocks = mempoolBlocks.getMempoolBlocks(); const mBlockDeltas = mempoolBlocks.getMempoolBlockDeltas(); const mempoolInfo = memPool.getMempoolInfo(); @@ -417,9 +417,8 @@ class WebsocketHandler { } const _memPool = memPool.getMempool(); - let matchRate; - if (config.MEMPOOL.ADVANCED_TRANSACTION_SELECTION) { + if (config.MEMPOOL.ADVANCED_GBT_AUDIT) { await mempoolBlocks.makeBlockTemplates(_memPool, 2); } else { mempoolBlocks.updateMempoolBlocks(_memPool); @@ -429,7 +428,7 @@ class WebsocketHandler { const projectedBlocks = mempoolBlocks.getMempoolBlocksWithTransactions(); const { censored, added, fresh, score } = Audit.auditBlock(transactions, projectedBlocks, _memPool); - matchRate = Math.round(score * 100 * 100) / 100; + const matchRate = Math.round(score * 100 * 100) / 100; const stripped = projectedBlocks[0]?.transactions ? projectedBlocks[0].transactions.map((tx) => { return { @@ -468,7 +467,7 @@ class WebsocketHandler { delete _memPool[txId]; } - if (config.MEMPOOL.ADVANCED_TRANSACTION_SELECTION) { + if (config.MEMPOOL.ADVANCED_GBT_MEMPOOL) { await mempoolBlocks.makeBlockTemplates(_memPool, 2); } else { mempoolBlocks.updateMempoolBlocks(_memPool); diff --git a/backend/src/config.ts b/backend/src/config.ts index 808e1406b..3a3d2b56d 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -29,7 +29,8 @@ interface IConfig { AUTOMATIC_BLOCK_REINDEXING: boolean; POOLS_JSON_URL: string, POOLS_JSON_TREE_URL: string, - ADVANCED_TRANSACTION_SELECTION: boolean; + ADVANCED_GBT_AUDIT: boolean; + ADVANCED_GBT_MEMPOOL: boolean; TRANSACTION_INDEXING: boolean; }; ESPLORA: { @@ -148,7 +149,8 @@ const defaults: IConfig = { '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', - 'ADVANCED_TRANSACTION_SELECTION': false, + 'ADVANCED_GBT_AUDIT': false, + 'ADVANCED_GBT_MEMPOOL': false, 'TRANSACTION_INDEXING': false, }, 'ESPLORA': {