diff --git a/lib/jobManager.js b/lib/jobManager.js index a66048c85..6be544368 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -126,13 +126,13 @@ var JobManager = module.exports = function JobManager(options){ }; - //returns true if processed a new block + //returns true if processed a new block OR the current block difficulty has changed this.processTemplate = function(rpcData){ /* Block is new if A) its the first block we have seen so far or B) the blockhash is different and the - block height is greater than the one we have */ + block height is greater than the one we have OR the current block difficulty has changed*/ var isNewBlock = typeof(_this.currentJob) === 'undefined'; - if (!isNewBlock && _this.currentJob.rpcData.previousblockhash !== rpcData.previousblockhash){ + if (!isNewBlock && ( _this.currentJob.rpcData.previousblockhash !== rpcData.previousblockhash || _this.currentJob.rpcData.bits !== rpcData.bits)){ isNewBlock = true; //If new block is outdated/out-of-sync than return diff --git a/lib/pool.js b/lib/pool.js index e5f52c9d7..ed38d7643 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -472,6 +472,9 @@ var pool = module.exports = function pool(options, authorizeFn){ }).on('broadcastTimeout', function(){ emitLog('No new blocks for ' + options.jobRebroadcastTimeout + ' seconds - updating transactions & rebroadcasting work'); + // send getblocktemplate to coin daemon to force the update of dynamic difficulty changes in DarkGravityWave algorithm... + _this.daemon.cmd('getblocktemplate', [], function(){}); + GetBlockTemplate(function(error, rpcData, processedBlock){ if (error || processedBlock) return; _this.jobManager.updateCurrentJob(rpcData); @@ -568,7 +571,7 @@ var pool = module.exports = function pool(options, authorizeFn){ blockPollingIntervalId = setInterval(function () { GetBlockTemplate(function(error, result, foundNewBlock){ if (foundNewBlock) - emitLog('Block notification via RPC polling'); + emitLog('Block notification or Block difficulty change via RPC polling'); }); }, pollingInterval); }