Merge pull request #48 from bluecircle/master

Fixes to resolve proxy switching
This commit is contained in:
Matthew Little 2014-04-08 09:30:16 -06:00
commit eed16e0f2e
2 changed files with 11 additions and 4 deletions

View File

@ -687,7 +687,6 @@ var pool = module.exports = function pool(options, authorizeFn){
function (clientsToRelinquish) {
clientsToRelinquish.forEach(function(cObj) {
cObj.client.removeAllListeners();
cObj.client.socket.removeAllListeners();
_this.stratumServer.removeStratumClientBySubId(cObj.subId);
});
@ -744,4 +743,4 @@ var pool = module.exports = function pool(options, authorizeFn){
};
};
pool.prototype.__proto__ = events.EventEmitter.prototype;
pool.prototype.__proto__ = events.EventEmitter.prototype;

View File

@ -208,7 +208,6 @@ var StratumClient = function(options){
return;
}
if (messageJson) {
handleMessage(messageJson);
}
@ -277,6 +276,12 @@ var StratumClient = function(options){
this.manuallyAuthClient = function (username, password) {
handleAuthorize({id: 1, params: [username, password]}, false /*do not reply to miner*/);
}
this.manuallySetValues = function (otherClient) {
_this.extraNonce1 = otherClient.extraNonce1;
_this.previousDifficulty = otherClient.previousDifficulty;
_this.difficulty = otherClient.difficulty;
}
};
StratumClient.prototype.__proto__ = events.EventEmitter.prototype;
@ -296,7 +301,7 @@ var StratumServer = exports.Server = function StratumServer(ports, connectionTim
var socketTimeout = connectionTimeout * 1000;
var bannedMS = banning ? banning.time * 1000 : null;
var _this = this;
var stratumClients = {};
var subscriptionCounter = SubscriptionCounter();
@ -338,6 +343,8 @@ var StratumServer = exports.Server = function StratumServer(ports, connectionTim
remoteAddress: socket.remoteAddress
}
);
stratumClients[subscriptionId] = client;
_this.emit('client.connected', client);
client.on('socketDisconnect', function() {
@ -403,6 +410,7 @@ var StratumServer = exports.Server = function StratumServer(ports, connectionTim
var subId = _this.handleNewClient(clientObj.socket);
if (subId != null) { // not banned!
stratumClients[subId].manuallyAuthClient(clientObj.workerName, clientObj.workerPass);
stratumClients[subId].manuallySetValues(clientObj);
}
}