From ae1c040cd7255ebe22cb4c798a508eb829de3461 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 4 Aug 2017 14:14:15 -0700 Subject: [PATCH] mempool: minor verification refactor. --- lib/mempool/mempool.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/mempool/mempool.js b/lib/mempool/mempool.js index 44dbeb06..4f91c4bf 100644 --- a/lib/mempool/mempool.js +++ b/lib/mempool/mempool.js @@ -961,21 +961,17 @@ Mempool.prototype.verify = async function verify(entry, view) { flags &= ~Script.flags.VERIFY_WITNESS; flags &= ~Script.flags.VERIFY_CLEANSTACK; - const valid1 = await this.verifyResult(tx, view, flags); - // If it failed, the first verification // was the only result we needed. - if (!valid1) + if (!await this.verifyResult(tx, view, flags)) throw err; // If it succeeded, segwit may be causing the // failure. Try with segwit but without cleanstack. flags |= Script.flags.VERIFY_CLEANSTACK; - const valid2 = await this.verifyResult(tx, view, flags); - // Cleanstack was causing the failure. - if (valid2) + if (await this.verifyResult(tx, view, flags)) throw err; // Do not insert into reject cache. @@ -986,8 +982,8 @@ Mempool.prototype.verify = async function verify(entry, view) { // Paranoid checks. if (this.options.paranoidChecks) { const flags = Script.flags.MANDATORY_VERIFY_FLAGS; - const valid = await this.verifyResult(tx, view, flags); - assert(valid, 'BUG: Verify failed for mandatory but not standard.'); + assert(await this.verifyResult(tx, view, flags), + 'BUG: Verify failed for mandatory but not standard.'); } };