diff --git a/lib/jobManager.js b/lib/jobManager.js index 4ce9317..dd320a5 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -125,7 +125,7 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest, }; - this.processShare = function(jobId, difficulty, extraNonce1, extraNonce2, nTime, nonce, ipAddress, workerName){ + this.processShare = function(jobId, previousDifficulty, difficulty, extraNonce1, extraNonce2, nTime, nonce, ipAddress, workerName){ var shareError = function(error){ _this.emit('share', { job: jobId, @@ -190,8 +190,15 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest, else { var targetUser = maxDifficulty.div(difficulty); if (headerBigNum.gt(targetUser)){ - var shareDiff = maxDifficulty.div(headerBigNum).toString(); - return shareError([23, 'low difficulty share of ' + shareDiff]); + //Check if share matched a previous difficulty from before vardiff retarget + if (previousDifficulty && !headerBigNum.gt(maxDifficulty.div(previousDifficulty))){ + difficulty = previousDifficulty; + } + else{ + var shareDiff = maxDifficulty.div(headerBigNum).toString(); + return shareError([23, 'low difficulty share of ' + shareDiff]); + } + } } if (!!blockHex) { diff --git a/lib/pool.js b/lib/pool.js index 58d5c43..f1127b6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -553,6 +553,7 @@ var pool = module.exports = function pool(options, authorizeFn){ }).on('submit', function(params, resultCallback){ var result =_this.jobManager.processShare( params.jobId, + client.previousDifficulty, client.difficulty, client.extraNonce1, params.extraNonce2, diff --git a/lib/stratum.js b/lib/stratum.js index 47f039e..3b9c272 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -240,6 +240,7 @@ var StratumClient = function(options){ if (difficulty === this.difficulty) return false; + _this.previousDifficulty = _this.difficulty; _this.difficulty = difficulty; sendJson({ id : null,