From d78df4b79cabf0bd22b2a175dda5a7517920f6a1 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 6 Sep 2017 14:21:23 -0700 Subject: [PATCH] miner: minor. --- lib/mining/miner.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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;