diff --git a/lib/hk-util.js b/lib/hk-util.js index a9b9f0eb1..b3f917693 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -926,6 +926,7 @@ HK.onDirectMessage = function (Env, Server, seq, userId, json) { const onChecked = Util.mkEvent(); + // Create our workers const workers = []; for (let i = 0; i < numCPUs; i++) { @@ -951,6 +952,12 @@ var initWorker = function (worker) { }; workers.forEach(initWorker); +const validateMessage = function (msg) { + nextWorker = (nextWorker + 1) % workers.length; + // Send the request + workers[nextWorker].send(msg); +}; + HK.onChannelMessage = function (Env, Server, channel, msgStruct) { console.log(+new Date(), "onChannelMessage"); const Log = Env.Log; @@ -1018,13 +1025,11 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct) { onChecked.reg(onCheck); console.log(+new Date(), "Send verification request"); - // Send the request - workers[nextWorker].send({ + validateMessage( { txid: txid, msg: signedMsg, key: metadata.validateKey }); - if (++nextWorker > numCPUs) { nextWorker = 0; } }).nThen(function () { // do checkpoint stuff...