From 9c1de721579aaebba5a07539816f482f805ae24b Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Sun, 22 Mar 2026 19:23:58 +0100 Subject: [PATCH] Refresh jobs when parent template blob changes --- lib/pool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9fc8d25..90574f3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -198,7 +198,10 @@ process.on('message', function (message) { let new_hash = Buffer.alloc(32); buffer.copy(new_hash, 0, previousOffset, 39); try { - if (!currentBlockTemplate[0] || new_hash.toString('hex') !== currentBlockTemplate[0].prev_hash.toString('hex') || (currentBlockTemplate[0].num_transactions == 0 && message.block.num_transactions > 0)) { + const prevHashChanged = !currentBlockTemplate[0] || new_hash.toString('hex') !== currentBlockTemplate[0].prev_hash.toString('hex'); + const txCountBecameNonZero = currentBlockTemplate[0] && currentBlockTemplate[0].num_transactions == 0 && message.block.num_transactions > 0; + const templateBlobChanged = currentBlockTemplate[0] && message.block.blocktemplate_blob !== currentBlockTemplate[0].blocktemplate_blob; + if (!currentBlockTemplate[0] || prevHashChanged || txCountBecameNonZero || templateBlobChanged) { log('info', logSystem, 'New %s block to mine at height %d w/ difficulty of %d (%d transactions)', [miningBackends.getActiveMiningBackend().coin, message.block.height, message.block.difficulty, (message.block.num_transactions || 0)]); processBlockTemplate(message.block); return;