Removed debuglogging

Moved the difficultyChanged code
This commit is contained in:
Andrea Baccega 2014-02-20 01:04:04 +01:00
parent 3ed4e93b5f
commit 969292c111
3 changed files with 10 additions and 12 deletions

View File

@ -152,7 +152,6 @@ var JobManager = module.exports = function JobManager(options){
}; };
this.processShare = function(jobId, difficulty, extraNonce1, extraNonce2, nTime, nonce, ipAddress, workerName){ this.processShare = function(jobId, difficulty, extraNonce1, extraNonce2, nTime, nonce, ipAddress, workerName){
console.log(difficulty);
var shareError = function(error){ var shareError = function(error){
_this.emit('share', { _this.emit('share', {
job: jobId, job: jobId,

View File

@ -139,10 +139,7 @@ var StratumClient = function(options){
}); });
} }
); );
if (_this.lastEmittedDiff !== _this.currentDifficulty){
_this.lastEmittedDiff = _this.currentDifficulty
_this.emit('difficultyChanged', _this.currentDifficulty);
}
} }
function sendJson(){ function sendJson(){
@ -234,8 +231,11 @@ var StratumClient = function(options){
this.sendMiningJob = function(jobParams){ this.sendMiningJob = function(jobParams){
if (pendingDifficulty !== null){ if (pendingDifficulty !== null){
_this.sendDifficulty(pendingDifficulty); var result = _this.sendDifficulty(pendingDifficulty);
pendingDifficulty = null; pendingDifficulty = null;
if (result) {
_this.emit('difficultyChanged', _this.difficulty);
}
} }
sendJson({ sendJson({
id : null, id : null,

View File

@ -42,7 +42,6 @@ function RingBuffer(maxSize){
var varDiff = module.exports = function varDiff(options, poolDifficulty){ var varDiff = module.exports = function varDiff(options, poolDifficulty){
console.log(options);
var _this = this; var _this = this;
var networkDifficulty; var networkDifficulty;
@ -78,7 +77,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.difficulty);
return; return;
} }
var sinceLast = ts - lastTs; var sinceLast = ts - lastTs;
@ -87,7 +86,7 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){
lastTs = ts; lastTs = ts;
if ((ts - lastRtc) < options.retargetTime && timeBuffer.size() > 0){ if ((ts - lastRtc) < options.retargetTime && timeBuffer.size() > 0){
console.log('do not retarget'); // console.log('do not retarget');
return; return;
} }
@ -107,15 +106,15 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){
var diffMax = networkDifficulty < options.maxDifficulty ? networkDifficulty : options.maxDifficulty; var diffMax = networkDifficulty < options.maxDifficulty ? networkDifficulty : options.maxDifficulty;
var diffMax = options.maxDifficulty; var diffMax = options.maxDifficulty;
console.log("Max & network", diffMax, networkDifficulty); // console.log("Max & network", diffMax, networkDifficulty);
if (ddiff * client.difficulty > diffMax) { if (ddiff * client.difficulty > diffMax) {
ddiff = diffMax / client.difficulty; ddiff = diffMax / client.difficulty;
} }
console.log('increasing difficulty, ddiff: ' + ddiff); // console.log('increasing difficulty, ddiff: ' + ddiff);
} }
else{ else{
console.log('hashrate in range ' + JSON.stringify({ddiff: ddiff, avg: avg}) ); // console.log('hashrate in range ' + JSON.stringify({ddiff: ddiff, avg: avg}) );
return; return;
} }