From df94faab9b1776b81e461626958d5dfd35fb8178 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sat, 1 Jul 2017 20:38:16 -0700 Subject: [PATCH] Small update to send all work to be done up to the Master thread. This should help deal with the fact that shares must be sent by one of the nodes that handles data. --- lib/pool.js | 5 +++++ lib/remote_comms.js | 11 ++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b687af9..f8c5bc2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -90,6 +90,11 @@ function messageHandler(message) { minerCount[message.data] += 1; } break; + case 'sendRemote': + if (cluster.isMaster) { + global.database.sendQueue.push(Buffer.from(message.data, 'hex')); + } + break; } } diff --git a/lib/remote_comms.js b/lib/remote_comms.js index d4ec4ee..0dff0dc 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -20,7 +20,7 @@ function Database() { function () { callback(); }); - }, 32); + }, 128); this.storeShare = function (blockId, shareData) { let wsData = global.protos.WSData.encode({ @@ -29,8 +29,7 @@ function Database() { msg: shareData, exInt: blockId }); - this.sendQueue.push({body: wsData}, function () { - }); + process.send({type: 'sendRemote', body: wsData.toString('hex')}); }; this.storeBlock = function (blockId, blockData) { @@ -40,8 +39,7 @@ function Database() { msg: blockData, exInt: blockId }); - this.sendQueue.push({body: wsData}, function () { - }); + process.send({type: 'sendRemote', body: wsData.toString('hex')}); }; this.storeInvalidShare = function (minerData) { @@ -51,8 +49,7 @@ function Database() { msg: minerData, exInt: 1 }); - this.sendQueue.push({body: wsData}, function () { - }); + process.send({type: 'sendRemote', body: wsData.toString('hex')}); }; this.initEnv = function(){