mempool: minor verification refactor.

This commit is contained in:
Christopher Jeffrey 2017-08-04 14:14:15 -07:00
parent 1d33816d89
commit ae1c040cd7
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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.');
}
};