Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
}
Expand Down