aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-03-21 13:03:16 +0000
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-03-21 13:03:16 +0000
commit15209d97c6aad7d5c199fe007ad39b91c8ee6562 (patch)
treeb6cd4379d9bb04f4817ff7a4f31f70eb7368edec
parentf4e42a78c75719ad6a99962360ec67d92a563a9d (diff)
consensus, refactor: Avoid `CScriptCheck::swap` in `CheckInputScripts`
-rw-r--r--src/validation.cpp3
-rw-r--r--src/validation.h5
2 files changed, 6 insertions, 2 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index d1b941f081..dce066412c 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1815,8 +1815,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
// Verify signature
CScriptCheck check(txdata.m_spent_outputs[i], tx, i, flags, cacheSigStore, &txdata);
if (pvChecks) {
- pvChecks->push_back(CScriptCheck());
- check.swap(pvChecks->back());
+ pvChecks->emplace_back(std::move(check));
} else if (!check()) {
if (flags & STANDARD_NOT_MANDATORY_VERIFY_FLAGS) {
// Check whether the failure was caused by a
diff --git a/src/validation.h b/src/validation.h
index 53e9a7ee50..7bcb35d9a4 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -322,6 +322,11 @@ public:
CScriptCheck(const CTxOut& outIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) :
m_tx_out(outIn), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { }
+ CScriptCheck(const CScriptCheck&) = delete;
+ CScriptCheck& operator=(const CScriptCheck&) = delete;
+ CScriptCheck(CScriptCheck&&) = default;
+ CScriptCheck& operator=(CScriptCheck&&) = default;
+
bool operator()();
void swap(CScriptCheck& check) noexcept