From 9c2b66e1fc2d4466255f3950ce35147889d73335 Mon Sep 17 00:00:00 2001 From: LigntingCash-Gold Developer <45900073+Lightningcash-dev@users.noreply.github.com> Date: Sun, 10 Mar 2019 06:42:48 -0400 Subject: [PATCH 1/3] Now updates diff correctly --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index e5f52c9d..7a5b83bb 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); From 6db683fc30dc6f28737e2646cb2561367ef3d5cd Mon Sep 17 00:00:00 2001 From: MerlinMagic2018 Date: Sun, 10 Mar 2019 23:16:14 -0400 Subject: [PATCH 2/3] Working Dynamic Block Difficulty Change Polling --- lib/jobManager.js | 6 +++--- lib/pool.js | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/jobManager.js b/lib/jobManager.js index a66048c8..6be54436 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 7a5b83bb..fe16eed6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -472,9 +472,6 @@ 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); @@ -571,7 +568,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); } From e0fc581a1e364fb62023831fd927182a95e9b1b6 Mon Sep 17 00:00:00 2001 From: LigntingCash-Gold Developer <45900073+Lightningcash-dev@users.noreply.github.com> Date: Mon, 11 Mar 2019 18:31:57 -0400 Subject: [PATCH 3/3] Forgot to include first commit change in second commit --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index fe16eed6..ed38d764 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);