diff --git a/lib/stratum.js b/lib/stratum.js index 568c4fe..5fa0ef1 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -40,7 +40,7 @@ var StratumClient = function(options){ handleSubscribe(message); break; case 'mining.authorize': - handleAuthorize(message); + handleAuthorize(message, true /*reply to socket*/); break; case 'mining.submit': handleSubmit(message); @@ -87,17 +87,20 @@ var StratumClient = function(options){ ); } - function handleAuthorize(message){ + function handleAuthorize(message, replyToSocket){ _this.workerIP = options.socket.address().address; _this.workerName = message.params[0]; _this.workerPass = message.params[1]; options.authorizeFn(_this.workerIP, _this.workerName, _this.workerPass, function(result) { _this.authorized = (!result.error && result.authorized); - sendJson({ - id : message.id, - result : _this.authorized, - error : result.error - }); + + if (replyToSocket) { + sendJson({ + id : message.id, + result : _this.authorized, + error : result.error + }); + } // If the authorizer wants us to close the socket lets do it. if (result.disconnect === true) { @@ -235,7 +238,7 @@ var StratumClient = function(options){ }; this.manuallyInitClient = function (username, password) { - handleAuthorize({id: 1, params: [username, password]}); + handleAuthorize({id: 1, params: [username, password]}, false /*do not reply to miner*/); handleSubscribe({id: 2}); } };