From f8ad649b4524d4b7b42f263c607c2389807503e2 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 18 Mar 2020 10:30:42 -0400 Subject: [PATCH] [style] bail out early to avoid nesting --- lib/hk-util.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/hk-util.js b/lib/hk-util.js index 915d5772e..2bcae56e3 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -1030,16 +1030,15 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct) { // Listen for messages //console.log(+new Date(), "Send verification request"); Env.validateMessage(signedMsg, metadata.validateKey, w(function (err) { - if (err) { - // validation can fail in multiple ways - if (err === 'FAILED') { - // 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(); + // no errors means success + if (!err) { return; } + // validation can fail in multiple ways + if (err === 'FAILED') { + // we log this case, but not others for some reason + Log.info("HK_SIGNED_MESSAGE_REJECTED", 'Channel '+channel.id); } - // otherwise it was successful! + // always abort if there was an error... + return void w.abort(); })); }).nThen(function () { // do checkpoint stuff...