Use each process in order instead of using a random one

This commit is contained in:
yflory 2020-03-17 15:10:23 +01:00
parent fb0eb1b20c
commit 923616aef0
1 changed files with 3 additions and 2 deletions

View File

@ -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...