From 8e3b28cea39800fee484d85a455839eec44c5f26 Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Wed, 15 Jan 2014 17:52:05 -0700 Subject: [PATCH] Fixed up error handling for stratum socket --- lib/pool.js | 2 +- lib/stratum.js | 7 +++++-- lib/vardiff.js | 0 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 lib/vardiff.js diff --git a/lib/pool.js b/lib/pool.js index d604070..2d0ca08 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -154,8 +154,8 @@ var pool = module.exports = function pool(options, authorizeFn){ if (error) emitErrorLog('system', 'Error with initial getblocktemplate'); else{ - StartStratumServer(); SetupBlockPolling(); + StartStratumServer(); } }); }); diff --git a/lib/stratum.js b/lib/stratum.js index 403ffc3..2ec91d8 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -178,8 +178,11 @@ var StratumClient = function(options){ socket.on('end', function() { _this.emit('socketDisconnect') }); - socket.on('error', function(){ - _this.emit('socketError'); + socket.on('error', function(err){ + if (err.code === 'ECONNRESET') + _this.emit('socketDisconnect') + else + _this.emit('socketError'); }); } diff --git a/lib/vardiff.js b/lib/vardiff.js new file mode 100644 index 0000000..e69de29