[style] bail out early to avoid nesting

This commit is contained in:
ansuz
2020-03-18 10:30:42 -04:00
parent 019e5e708b
commit f8ad649b45

View File

@@ -1030,16 +1030,15 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct) {
// Listen for messages // Listen for messages
//console.log(+new Date(), "Send verification request"); //console.log(+new Date(), "Send verification request");
Env.validateMessage(signedMsg, metadata.validateKey, w(function (err) { Env.validateMessage(signedMsg, metadata.validateKey, w(function (err) {
if (err) { // no errors means success
// validation can fail in multiple ways if (!err) { return; }
if (err === 'FAILED') { // validation can fail in multiple ways
// we log this case, but not others for some reason if (err === 'FAILED') {
Log.info("HK_SIGNED_MESSAGE_REJECTED", 'Channel '+channel.id); // we log this case, but not others for some reason
} Log.info("HK_SIGNED_MESSAGE_REJECTED", 'Channel '+channel.id);
// always abort if there was an error...
return void w.abort();
} }
// otherwise it was successful! // always abort if there was an error...
return void w.abort();
})); }));
}).nThen(function () { }).nThen(function () {
// do checkpoint stuff... // do checkpoint stuff...