diff --git a/README.md b/README.md index 74724a8..3aab291 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ pool.on('share', function(isValidShare, isValidBlock, data){ */ pool.on('log', function(severity, logKey, logText){ console.log(severity + ': ' + '[' + logKey + '] ' + logText); -}; +}); ``` Start pool diff --git a/lib/pool.js b/lib/pool.js index bb6fd72..60a4a3f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -230,7 +230,9 @@ var pool = module.exports = function pool(options, authorizeFn){ if (options.varDiff.enabled) _this.varDiff.manageClient(client); - client.on('subscription', function(params, resultCallback){ + client.on('difficultyChanged', function(diff){ + _this.emit('difficultyUpdate', client.workerName, diff); + }).on('subscription', function(params, resultCallback){ var extraNonce = _this.jobManager.extraNonceCounter.next(); var extraNonce2Size = _this.jobManager.extraNonce2Size; diff --git a/lib/stratum.js b/lib/stratum.js index 66bc1d8..377f48f 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -141,6 +141,10 @@ var StratumClient = function(options){ }); } ); + if (_this.lastEmittedDiff !== _this.difficulty){ + _this.lastEmittedDiff = _this.difficulty + _this.emit('difficultyChanged', _this.difficulty); + } } function sendJson(){