From 1b098b61baacea80365073a63f1291ab1e947435 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 10 Mar 2017 05:03:59 -0800 Subject: [PATCH] template: minor. --- lib/mining/cpuminer.js | 1 - lib/mining/template.js | 16 +++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/mining/cpuminer.js b/lib/mining/cpuminer.js index 7f5fecce..71c23650 100644 --- a/lib/mining/cpuminer.js +++ b/lib/mining/cpuminer.js @@ -75,7 +75,6 @@ CPUMiner.prototype._init = function _init() { }); this.on('status', function(stat) { - // Send progress report. self.logger.info( 'CPUMiner: hashrate=%dkhs hashes=%d target=%d height=%d best=%s', stat.hashrate / 1000 | 0, diff --git a/lib/mining/template.js b/lib/mining/template.js index 59d8991d..662b299f 100644 --- a/lib/mining/template.js +++ b/lib/mining/template.js @@ -105,18 +105,17 @@ BlockTemplate.prototype.createCoinbase = function createCoinbase() { input = new Input(); // Height (required in v2+ blocks) - input.script.set(0, new BN(this.height)); + input.script.push(new BN(this.height)); - // Let the world know this little - // miner succeeded. - input.script.set(1, encoding.ZERO_HASH160); + // Coinbase flags. + input.script.push(encoding.ZERO_HASH160); // Smaller nonce for good measure. - input.script.set(2, util.nonce().slice(0, 4)); + input.script.push(util.nonce().slice(0, 4)); - // extraNonce - incremented when + // Extra nonce: incremented when // the nonce overflows. - input.script.set(3, extraNonce(0, 0)); + input.script.push(extraNonce(0, 0)); input.script.compile(); @@ -180,6 +179,9 @@ BlockTemplate.prototype.createCoinbase = function createCoinbase() { cb.refresh(); + assert(input.script.getSize() <= 100, + 'Coinbase input script is too large!'); + return cb; };