diff --git a/lib/pool.js b/lib/pool.js index c464d1301..e520ff6a0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -112,6 +112,8 @@ function BlockTemplate(template){ this.reserveOffset = template.reserved_offset; this.buffer = new Buffer(this.blob, 'hex'); instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 3); + this.previous_hash = new Buffer(32); + this.buffer.copy(this.previous_hash,0,7,39); this.extraNonce = 0; } BlockTemplate.prototype = { @@ -141,7 +143,10 @@ function jobRefresh(loop, callback){ callback(false); return; } - if (!currentBlockTemplate || result.height > currentBlockTemplate.height){ + var buffer = new Buffer(result.blocktemplate_blob, 'hex'); + var previous_hash = new Buffer(32); + buffer.copy(previous_hash,0,7,39); + if (!currentBlockTemplate || ( previous_hash.toString('hex') != currentBlockTemplate.previous_hash.toString('hex') && result.height >= currentBlockTemplate.height )) log('info', logSystem, 'New block to mine at height %d w/ difficulty of %d', [result.height, result.difficulty]); processBlockTemplate(result); }