Updated readme desc
This commit is contained in:
parent
fce8d5b1b8
commit
7dbcc4f863
|
@ -87,6 +87,7 @@ var pool = Stratum.createPool({
|
|||
|
||||
//instanceId: 37, //Recommend not using this because a crypto-random one will be generated
|
||||
|
||||
"connectionTimeout": 120, //Remove workers that haven't been in contact for this many seconds
|
||||
|
||||
/* Each pool can have as many ports for your miners to connect to as you wish. Each port can
|
||||
be configured to use its own pool difficulty and variable difficulty settings. varDiff is
|
||||
|
|
|
@ -39,6 +39,8 @@ function DaemonInterface(options){
|
|||
return !results.error;
|
||||
});
|
||||
callback(allOnline);
|
||||
if (!allOnline)
|
||||
_this.emit('connectionFailed', results);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ var events = require('events');
|
|||
|
||||
var pool = require('./pool.js');
|
||||
|
||||
exports.daemon = require('./daemon.js');
|
||||
|
||||
exports.createPool = function(poolOptions, authorizeFn){
|
||||
var newPool = new pool(poolOptions, authorizeFn);
|
||||
return newPool;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,6 +4,10 @@ var events = require('events');
|
|||
|
||||
var util = require('./util.js');
|
||||
|
||||
|
||||
//Example of p2p in node from TheSeven: http://paste.pm/e54.js
|
||||
|
||||
|
||||
var commandStringBuffer = function(s){
|
||||
var buff = new Buffer(12);
|
||||
buff.fill(0);
|
||||
|
|
|
@ -317,8 +317,8 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||
}
|
||||
});
|
||||
|
||||
}).on('connectionFailed', function(instance){
|
||||
emitErrorLog('system','Failed to start daemon');
|
||||
}).on('connectionFailed', function(error){
|
||||
emitErrorLog('system','Failed to connect daemon(s): ' + JSON.stringify(error));
|
||||
}).on('error', function(message){
|
||||
emitErrorLog('system', message);
|
||||
});
|
||||
|
@ -328,7 +328,7 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||
|
||||
|
||||
function StartStratumServer(){
|
||||
_this.stratumServer = new stratum.Server(options.ports, authorizeFn);
|
||||
_this.stratumServer = new stratum.Server(options.ports, options.connectionTimeout, authorizeFn);
|
||||
_this.stratumServer.on('started', function(){
|
||||
emitLog('system','Stratum server started on port(s): ' + Object.keys(options.ports).join(', '));
|
||||
_this.emit('started');
|
||||
|
@ -480,5 +480,4 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||
}
|
||||
|
||||
};
|
||||
pool.prototype.__proto__ = events.EventEmitter.prototype;
|
||||
pool.daemon = daemon;
|
||||
pool.prototype.__proto__ = events.EventEmitter.prototype;
|
|
@ -30,6 +30,9 @@ var StratumClient = function(options){
|
|||
|
||||
var _this = this;
|
||||
|
||||
this.lastActivity = Date.now();
|
||||
|
||||
|
||||
(function init(){
|
||||
setupSocket();
|
||||
})();
|
||||
|
@ -43,15 +46,16 @@ var StratumClient = function(options){
|
|||
handleAuthorize(message, true /*reply to socket*/);
|
||||
break;
|
||||
case 'mining.submit':
|
||||
_this.lastActivity = Date.now();
|
||||
handleSubmit(message);
|
||||
break;
|
||||
case 'mining.get_transactions':
|
||||
/*case 'mining.get_transactions':
|
||||
sendJson({
|
||||
id : null,
|
||||
result : [],
|
||||
error : true
|
||||
});
|
||||
break;
|
||||
break;*/
|
||||
default:
|
||||
_this.emit('unknownStratumMethod', message);
|
||||
break;
|
||||
|
@ -254,7 +258,7 @@ StratumClient.prototype.__proto__ = events.EventEmitter.prototype;
|
|||
* - 'client.disconnected'(StratumClientInstance) - when a miner disconnects. Be aware that the socket cannot be used anymore.
|
||||
* - 'started' - when the server is up and running
|
||||
**/
|
||||
var StratumServer = exports.Server = function StratumServer(ports, authorizeFn){
|
||||
var StratumServer = exports.Server = function StratumServer(ports, connectionTimeout, authorizeFn){
|
||||
|
||||
//private members
|
||||
|
||||
|
@ -300,8 +304,13 @@ var StratumServer = exports.Server = function StratumServer(ports, authorizeFn){
|
|||
for (var clientId in stratumClients) {
|
||||
// if a client gets disconnected WHILE doing this loop a crash might happen.
|
||||
// 'm not sure if that can ever happn but an if here doesn't hurt!
|
||||
if (typeof(stratumClients[clientId]) !== 'undefined') {
|
||||
stratumClients[clientId].sendMiningJob(jobParams);
|
||||
var client = stratumClients[clientId];
|
||||
if (typeof(client) !== 'undefined') {
|
||||
if (Date.now() - client.lastActivity > connectionTimeout){
|
||||
client.socket.end();
|
||||
return;
|
||||
}
|
||||
client.sendMiningJob(jobParams);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue