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){
|
var shareError = function(error){
|
||||||
_this.emit('share', {
|
_this.emit('share', {
|
||||||
job: jobId,
|
job: jobId,
|
||||||
@ -190,8 +190,15 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
|||||||
else {
|
else {
|
||||||
var targetUser = maxDifficulty.div(difficulty);
|
var targetUser = maxDifficulty.div(difficulty);
|
||||||
if (headerBigNum.gt(targetUser)){
|
if (headerBigNum.gt(targetUser)){
|
||||||
var shareDiff = maxDifficulty.div(headerBigNum).toString();
|
//Check if share matched a previous difficulty from before vardiff retarget
|
||||||
return shareError([23, 'low difficulty share of ' + shareDiff]);
|
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) {
|
if (!!blockHex) {
|
||||||
|
|||||||
@ -553,6 +553,7 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||||||
}).on('submit', function(params, resultCallback){
|
}).on('submit', function(params, resultCallback){
|
||||||
var result =_this.jobManager.processShare(
|
var result =_this.jobManager.processShare(
|
||||||
params.jobId,
|
params.jobId,
|
||||||
|
client.previousDifficulty,
|
||||||
client.difficulty,
|
client.difficulty,
|
||||||
client.extraNonce1,
|
client.extraNonce1,
|
||||||
params.extraNonce2,
|
params.extraNonce2,
|
||||||
|
|||||||
@ -240,6 +240,7 @@ var StratumClient = function(options){
|
|||||||
if (difficulty === this.difficulty)
|
if (difficulty === this.difficulty)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
_this.previousDifficulty = _this.difficulty;
|
||||||
_this.difficulty = difficulty;
|
_this.difficulty = difficulty;
|
||||||
sendJson({
|
sendJson({
|
||||||
id : null,
|
id : null,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user