diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1068,9 +1068,16 @@ // Verify signature CScriptCheck check(coin.GetTxOut(), tx, i, flags, sigCacheStore, txdata, &txLimitSigChecks, pBlockLimitSigChecks); + + // If pvChecks is not null, move the input check and skip running it. + // The sigcheck count will not be added to the total. if (pvChecks) { pvChecks->push_back(std::move(check)); - } else if (!check()) { + continue; + } + + // If pvChecks is null, run the check; if it fails, try to figure why. + if (!check()) { ScriptError scriptError = check.GetScriptError(); // Compute flags without the optional standardness flags. // This differs from MANDATORY_SCRIPT_VERIFY_FLAGS as it contains @@ -1097,8 +1104,8 @@ } // MANDATORY flag failures correspond to - // TxValidationResult::TX_CONSENSUS. Because CONSENSUS failures - // are the most serious case of validation failures, we may need to + // TxValidationResult::TX_CONSENSUS. Because CONSENSUS failures are + // the most serious case of validation failures, we may need to // consider using RECENT_CONSENSUS_CHANGE for any script failure // that could be due to non-upgraded nodes which we may want to // support, to avoid splitting the network (but this depends on the @@ -1109,6 +1116,8 @@ ScriptErrorString(scriptError))); } + // We reached this point if pvChecks is null and the check succeeded for + // this input; add its sigcheck count to the total. nSigChecksTotal += check.GetScriptExecutionMetrics().nSigChecks; }