Vardiff perfect fix

This commit is contained in:
Matt 2014-02-19 16:07:25 -07:00
parent 96cfc412a8
commit 9d8255a620
3 changed files with 11 additions and 10 deletions

View File

@ -284,7 +284,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.difficulty, client.currentDifficulty,
client.extraNonce1, client.extraNonce1,
params.extraNonce2, params.extraNonce2,
params.nTime, params.nTime,

View File

@ -139,9 +139,9 @@ var StratumClient = function(options){
}); });
} }
); );
if (_this.lastEmittedDiff !== _this.difficulty){ if (_this.lastEmittedDiff !== _this.currentDifficulty){
_this.lastEmittedDiff = _this.difficulty _this.lastEmittedDiff = _this.currentDifficulty
_this.emit('difficultyChanged', _this.difficulty); _this.emit('difficultyChanged', _this.currentDifficulty);
} }
} }
@ -207,7 +207,7 @@ var StratumClient = function(options){
} }
if (difficulty !== this.difficulty) { if (difficulty !== this.difficulty) {
this.difficulty = difficulty; _this.latestDifficulty = difficulty;
sendJson({ sendJson({
id : null, id : null,
method: "mining.set_difficulty", method: "mining.set_difficulty",
@ -226,6 +226,7 @@ var StratumClient = function(options){
method: "mining.notify", method: "mining.notify",
params: jobParams params: jobParams
}); });
_this.currentDifficulty = _this.latestDifficulty
}; };
}; };
StratumClient.prototype.__proto__ = events.EventEmitter.prototype; StratumClient.prototype.__proto__ = events.EventEmitter.prototype;

View File

@ -78,7 +78,7 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){
lastRtc = ts - options.retargetTime / 2; lastRtc = ts - options.retargetTime / 2;
lastTs = ts; lastTs = ts;
timeBuffer = new RingBuffer(bufferSize); timeBuffer = new RingBuffer(bufferSize);
console.log(bufferSize+ ' first time share vardiff curdiff: '+client.difficulty); console.log(bufferSize+ ' first time share vardiff curdiff: '+client.currentDifficulty);
return; return;
} }
var sinceLast = ts - lastTs; var sinceLast = ts - lastTs;
@ -97,10 +97,10 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){
var ddiff; var ddiff;
if (avg > tMax && client.difficulty > options.minDifficulty) { if (avg > tMax && client.currentDifficulty > options.minDifficulty) {
ddiff = 0.5; ddiff = 0.5;
if (ddiff * client.difficulty < options.minDifficulty) { if (ddiff * client.currentDifficulty < options.minDifficulty) {
ddiff = options.minDifficulty / client.difficulty; ddiff = options.minDifficulty / client.currentDifficulty;
} }
} else if (avg < tMin) { } else if (avg < tMin) {
ddiff = 2; ddiff = 2;
@ -119,7 +119,7 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){
return; return;
} }
var newDiff = client.difficulty * ddiff; var newDiff = client.currentDifficulty * ddiff;
timeBuffer.clear(); timeBuffer.clear();
//console.log('sending new difficutly ' + newDiff); //console.log('sending new difficutly ' + newDiff);