From a61679c4a9d40a68ac7af9f43bcc42269b81957f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 26 Jan 2017 20:41:09 -0800 Subject: [PATCH] miner: 4 byte nonces. --- lib/mining/minerblock.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/mining/minerblock.js b/lib/mining/minerblock.js index 670b8861..222b9e70 100644 --- a/lib/mining/minerblock.js +++ b/lib/mining/minerblock.js @@ -232,8 +232,8 @@ MinerBlock.prototype.updateNonce = function updateNonce() { this.block.nonce = 0; this.nonce1++; - // Wrap at 6 bytes. - if (this.nonce1 === 0xffffffffffff) { + // Wrap at 4 bytes. + if (this.nonce1 === 0xffffffff) { this.nonce1 = 0; this.nonce2++; } @@ -270,11 +270,9 @@ MinerBlock.prototype.updateMerkle = function updateMerkle() { */ MinerBlock.prototype.extraNonce = function extraNonce() { - var bw = new StaticWriter(12); - bw.writeU32BE(this.nonce1 / 0x10000 | 0); - bw.writeU16BE(this.nonce1 & 0xffff); - bw.writeU32BE(this.nonce2 / 0x10000 | 0); - bw.writeU16BE(this.nonce2 & 0xffff); + var bw = new StaticWriter(8); + bw.writeU32BE(this.nonce1); + bw.writeU32BE(this.nonce2); return bw.render(); };