miner: 4 byte nonces.

This commit is contained in:
Christopher Jeffrey 2017-01-26 20:41:09 -08:00
parent 8e6819714b
commit a61679c4a9
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -232,8 +232,8 @@ MinerBlock.prototype.updateNonce = function updateNonce() {
this.block.nonce = 0; this.block.nonce = 0;
this.nonce1++; this.nonce1++;
// Wrap at 6 bytes. // Wrap at 4 bytes.
if (this.nonce1 === 0xffffffffffff) { if (this.nonce1 === 0xffffffff) {
this.nonce1 = 0; this.nonce1 = 0;
this.nonce2++; this.nonce2++;
} }
@ -270,11 +270,9 @@ MinerBlock.prototype.updateMerkle = function updateMerkle() {
*/ */
MinerBlock.prototype.extraNonce = function extraNonce() { MinerBlock.prototype.extraNonce = function extraNonce() {
var bw = new StaticWriter(12); var bw = new StaticWriter(8);
bw.writeU32BE(this.nonce1 / 0x10000 | 0); bw.writeU32BE(this.nonce1);
bw.writeU16BE(this.nonce1 & 0xffff); bw.writeU32BE(this.nonce2);
bw.writeU32BE(this.nonce2 / 0x10000 | 0);
bw.writeU16BE(this.nonce2 & 0xffff);
return bw.render(); return bw.render();
}; };