Moving share validation into remoteShare before it ever gets to our internal processing DB loop.

This commit is contained in:
Alexander Blair
2017-05-19 16:54:20 -07:00
parent cdf17d4e70
commit 063b206d46
2 changed files with 10 additions and 2 deletions
+7 -1
View File
@@ -37,7 +37,11 @@ app.post('/leafApi', function (req, res) {
}
switch (msgData.msgType) {
case global.protos.MESSAGETYPE.SHARE:
process.send({block: msgData.exInt, data: msgData.msg});
try {
global.protos.Share.decode(msgData.msg);
process.send({block: msgData.exInt, data: msgData.msg});
} catch (e){
}
return res.json({'success': true});
case global.protos.MESSAGETYPE.BLOCK:
global.database.storeBlock(msgData.exInt, msgData.msg, function(data){
@@ -80,6 +84,7 @@ if (cluster.isMaster) {
for (let i = 0; i < numWorkers; i++) {
let worker = cluster.fork();
worker.on('message', messageHandler);
workerList.push(worker);
}
@@ -91,6 +96,7 @@ if (cluster.isMaster) {
console.log('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal);
console.log('Starting a new worker');
worker = cluster.fork();
worker.on('message', messageHandler);
workerList.push(worker);
});
} else {