Skip to content

Commit

Permalink
Bugfix while pool connection
Browse files Browse the repository at this point in the history
  • Loading branch information
BScrk committed Oct 30, 2017
1 parent 3c4edac commit b8f14c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lib/pool_connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var PoolConnector = function(restartCallback){
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.onEnd = function() {
logger.log('Pool closed the connection...');
this.reconnect();
this.reset();
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.send = function(obj){
Expand Down Expand Up @@ -160,11 +160,13 @@ var PoolConnector = function(restartCallback){
this.poolSocket.on('end',()=>{this.onEnd();});
}else{
logger.err('All connections failed...');
this.reconnect();
this.reset();
}
}

this.reconnect = function () {
this.reset = function () {
logger.err('Closing all connections...');
this.destroy();
logger.err("Waiting 10 seconds before attempting to restart the Stratum Proxy");
setTimeout( () => { restartCallback(); },10000);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zecproxy",
"version": "1.0.5",
"version": "1.0.6",
"description": "Zcash Stratum Proxy",
"main": "proxy.js",
"scripts": {},
Expand Down
6 changes: 4 additions & 2 deletions proxy.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@

var remotePool = require('./lib/pool_connector.js');
var logger = require('./lib/stratum_logger.js');
var info = require('./package.json');

var poolProxy = null;



var startStratum = function() {
logger.log("ZEC STRATUM PROXY STARTING...");
logger.log("ZEC STRATUM PROXY "+ info.version +" STARTING...");
poolProxy = new remotePool.PoolConnector(restartStratum);
}

var restartStratum = function() {
logger.warn("ZEC STRATUM PROXY RESTARTING...");
logger.warn("ZEC STRATUM PROXY RESETING...");
poolProxy.destroy();
delete poolProxy;
startStratum();
Expand Down

0 comments on commit b8f14c7

Please sign in to comment.