diff --git a/lib/mining/miner.js b/lib/mining/miner.js index e6fdd7e0e..1a050465e 100644 --- a/lib/mining/miner.js +++ b/lib/mining/miner.js @@ -250,13 +250,6 @@ Miner.prototype.getAddress = function getAddress() { */ Miner.prototype.assemble = function assemble(attempt) { - let priority = this.options.priorityWeight > 0; - const queue = new Heap(cmpRate); - const depMap = new Map(); - - if (priority) - queue.set(cmpPriority); - if (!this.mempool) { attempt.refresh(); return; @@ -265,6 +258,14 @@ Miner.prototype.assemble = function assemble(attempt) { assert(this.mempool.tip === this.chain.tip.hash, 'Mempool/chain tip mismatch! Unsafe to create block.'); + const depMap = new Map(); + const queue = new Heap(cmpRate); + + let priority = this.options.priorityWeight > 0; + + if (priority) + queue.set(cmpPriority); + for (const entry of this.mempool.map.values()) { const item = BlockEntry.fromEntry(entry, attempt); const tx = item.tx; @@ -296,6 +297,7 @@ Miner.prototype.assemble = function assemble(attempt) { const item = queue.shift(); const tx = item.tx; const hash = item.hash; + let weight = attempt.weight; let sigops = attempt.sigops;