diff --git a/lib/jobManager.js b/lib/jobManager.js index c47bf6c..3b704e0 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -152,7 +152,6 @@ var JobManager = module.exports = function JobManager(options){ }; this.processShare = function(jobId, difficulty, extraNonce1, extraNonce2, nTime, nonce, ipAddress, workerName){ - console.log(difficulty); var shareError = function(error){ _this.emit('share', { job: jobId, diff --git a/lib/stratum.js b/lib/stratum.js index 19f8482..bf92900 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -139,10 +139,7 @@ var StratumClient = function(options){ }); } ); - if (_this.lastEmittedDiff !== _this.currentDifficulty){ - _this.lastEmittedDiff = _this.currentDifficulty - _this.emit('difficultyChanged', _this.currentDifficulty); - } + } function sendJson(){ @@ -234,8 +231,11 @@ var StratumClient = function(options){ this.sendMiningJob = function(jobParams){ if (pendingDifficulty !== null){ - _this.sendDifficulty(pendingDifficulty); + var result = _this.sendDifficulty(pendingDifficulty); pendingDifficulty = null; + if (result) { + _this.emit('difficultyChanged', _this.difficulty); + } } sendJson({ id : null, diff --git a/lib/varDiff.js b/lib/varDiff.js index 494a3ef..1b80236 100644 --- a/lib/varDiff.js +++ b/lib/varDiff.js @@ -42,7 +42,6 @@ function RingBuffer(maxSize){ var varDiff = module.exports = function varDiff(options, poolDifficulty){ - console.log(options); var _this = this; var networkDifficulty; @@ -78,7 +77,7 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){ lastRtc = ts - options.retargetTime / 2; lastTs = ts; 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; } var sinceLast = ts - lastTs; @@ -87,7 +86,7 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){ lastTs = ts; if ((ts - lastRtc) < options.retargetTime && timeBuffer.size() > 0){ - console.log('do not retarget'); + // console.log('do not retarget'); return; } @@ -107,15 +106,15 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){ var diffMax = networkDifficulty < options.maxDifficulty ? networkDifficulty : options.maxDifficulty; var diffMax = options.maxDifficulty; - console.log("Max & network", diffMax, networkDifficulty); + // console.log("Max & network", diffMax, networkDifficulty); if (ddiff * client.difficulty > diffMax) { ddiff = diffMax / client.difficulty; } - console.log('increasing difficulty, ddiff: ' + ddiff); + // console.log('increasing difficulty, ddiff: ' + ddiff); } else{ - console.log('hashrate in range ' + JSON.stringify({ddiff: ddiff, avg: avg}) ); + // console.log('hashrate in range ' + JSON.stringify({ddiff: ddiff, avg: avg}) ); return; }