Use each process in order instead of using a random one

pull/1/head
yflory 5 years ago
parent fb0eb1b20c
commit 923616aef0

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

Loading…
Cancel
Save