Added check to see if a submitted share matched a miner's previous difficulty from before vardiff retarget.
This commit is contained in:
parent
1e9bd77072
commit
7d5c7ed277
@ -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) {
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -240,6 +240,7 @@ var StratumClient = function(options){
|
||||
if (difficulty === this.difficulty)
|
||||
return false;
|
||||
|
||||
_this.previousDifficulty = _this.difficulty;
|
||||
_this.difficulty = difficulty;
|
||||
sendJson({
|
||||
id : null,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user