|
|
|
@ -924,17 +924,20 @@ HK.onDirectMessage = function (Env, Server, seq, userId, json) {
|
|
|
|
|
* writes messages to the store
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
HK.initializeValidationWorkers = function (Env) {
|
|
|
|
|
if (typeof(Env.validateMessage) !== 'undefined') {
|
|
|
|
|
return void console.error("validation workers are already initialized");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create our workers
|
|
|
|
|
const workers = [];
|
|
|
|
|
for (let i = 0; i < numCPUs; i++) {
|
|
|
|
|
// Create our workers
|
|
|
|
|
const workers = [];
|
|
|
|
|
for (let i = 0; i < numCPUs; i++) {
|
|
|
|
|
workers.push(fork('lib/check-signature.js'));
|
|
|
|
|
}
|
|
|
|
|
var nextWorker = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const response = Util.response();
|
|
|
|
|
const response = Util.response();
|
|
|
|
|
|
|
|
|
|
var initWorker = function (worker) {
|
|
|
|
|
var initWorker = function (worker) {
|
|
|
|
|
worker.on('message', function (res) {
|
|
|
|
|
if (!res || !res.txid) { return; }
|
|
|
|
|
//console.log(+new Date(), "Received verification response");
|
|
|
|
@ -952,11 +955,11 @@ var initWorker = function (worker) {
|
|
|
|
|
workers.push(w);
|
|
|
|
|
initWorker(w);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
workers.forEach(initWorker);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
workers.forEach(initWorker);
|
|
|
|
|
|
|
|
|
|
const validateMessage = function (signedMsg, key, _cb) {
|
|
|
|
|
var nextWorker = 0;
|
|
|
|
|
Env.validateMessage = function (signedMsg, key, _cb) {
|
|
|
|
|
// let's be paranoid about asynchrony and only calling back once..
|
|
|
|
|
var cb = Util.once(Util.mkAsync(_cb));
|
|
|
|
|
|
|
|
|
@ -977,6 +980,7 @@ const validateMessage = function (signedMsg, key, _cb) {
|
|
|
|
|
msg: signedMsg,
|
|
|
|
|
key: key,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
HK.onChannelMessage = function (Env, Server, channel, msgStruct) {
|
|
|
|
@ -1025,7 +1029,7 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct) {
|
|
|
|
|
|
|
|
|
|
// Listen for messages
|
|
|
|
|
//console.log(+new Date(), "Send verification request");
|
|
|
|
|
validateMessage(signedMsg, metadata.validateKey, w(function (err) {
|
|
|
|
|
Env.validateMessage(signedMsg, metadata.validateKey, w(function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
// validation can fail in multiple ways
|
|
|
|
|
if (err === 'FAILED') {
|
|
|
|
|