diff --git a/lib/hk-util.js b/lib/hk-util.js index 889d5d0b0..a9b9f0eb1 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -931,6 +931,7 @@ const workers = []; for (let i = 0; i < numCPUs; i++) { workers.push(fork('lib/check-signature.js')); } +var nextWorker = 0; var initWorker = function (worker) { worker.on('message', function (res) { onChecked.fire(res); @@ -1018,12 +1019,12 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct) { console.log(+new Date(), "Send verification request"); // Send the request - const random = Math.floor(Math.random() * 4); - workers[random].send({ + workers[nextWorker].send({ txid: txid, msg: signedMsg, key: metadata.validateKey }); + if (++nextWorker > numCPUs) { nextWorker = 0; } }).nThen(function () { // do checkpoint stuff...