From 923616aef05114c7b24cfdeaf01b25566617eddf Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 17 Mar 2020 15:10:23 +0100 Subject: [PATCH] Use each process in order instead of using a random one --- lib/hk-util.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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...