mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Merge bitcoin/bitcoin#25694: refactor: Make CTransaction constructor explicit
fa2247a9f9
refactor: Make CTransaction constructor explicit (MacroFake) Pull request description: It involves calculating two hashes, so the performance impact should be made explicit. Also, add the module to iwyu. ACKs for top commit: aureleoules: ACKfa2247a9f9
. hebasto: ACKfa2247a9f9
, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: e236c352a472c7edfd4f0319a5a16a59f627b0ab7eb8531b53c75d730a3fa3e990a939978dcd952cd73e647925fc79bfa6d9fd87624bbc3ef180f40f95acef19
This commit is contained in:
commit
c90f86e4c7
4 changed files with 30 additions and 16 deletions
|
@ -47,6 +47,7 @@ if [ "${RUN_TIDY}" = "true" ]; then
|
||||||
" src/policy/feerate.cpp"\
|
" src/policy/feerate.cpp"\
|
||||||
" src/policy/packages.cpp"\
|
" src/policy/packages.cpp"\
|
||||||
" src/policy/settings.cpp"\
|
" src/policy/settings.cpp"\
|
||||||
|
" src/primitives/transaction.cpp"\
|
||||||
" src/rpc/fees.cpp"\
|
" src/rpc/fees.cpp"\
|
||||||
" src/rpc/signmessage.cpp"\
|
" src/rpc/signmessage.cpp"\
|
||||||
" src/test/fuzz/txorphan.cpp"\
|
" src/test/fuzz/txorphan.cpp"\
|
||||||
|
|
|
@ -7,10 +7,15 @@
|
||||||
|
|
||||||
#include <consensus/amount.h>
|
#include <consensus/amount.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
#include <script/script.h>
|
||||||
|
#include <serialize.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
|
#include <uint256.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
#include <version.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
std::string COutPoint::ToString() const
|
std::string COutPoint::ToString() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,13 +6,21 @@
|
||||||
#ifndef BITCOIN_PRIMITIVES_TRANSACTION_H
|
#ifndef BITCOIN_PRIMITIVES_TRANSACTION_H
|
||||||
#define BITCOIN_PRIMITIVES_TRANSACTION_H
|
#define BITCOIN_PRIMITIVES_TRANSACTION_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <consensus/amount.h>
|
#include <consensus/amount.h>
|
||||||
|
#include <prevector.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
#include <serialize.h>
|
#include <serialize.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <ios>
|
||||||
|
#include <limits>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag that is ORed into the protocol version to designate that a transaction
|
* A flag that is ORed into the protocol version to designate that a transaction
|
||||||
|
@ -303,7 +311,7 @@ private:
|
||||||
public:
|
public:
|
||||||
/** Convert a CMutableTransaction into a CTransaction. */
|
/** Convert a CMutableTransaction into a CTransaction. */
|
||||||
explicit CTransaction(const CMutableTransaction& tx);
|
explicit CTransaction(const CMutableTransaction& tx);
|
||||||
CTransaction(CMutableTransaction&& tx);
|
explicit CTransaction(CMutableTransaction&& tx);
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
inline void Serialize(Stream& s) const {
|
inline void Serialize(Stream& s) const {
|
||||||
|
@ -368,7 +376,7 @@ struct CMutableTransaction
|
||||||
int32_t nVersion;
|
int32_t nVersion;
|
||||||
uint32_t nLockTime;
|
uint32_t nLockTime;
|
||||||
|
|
||||||
CMutableTransaction();
|
explicit CMutableTransaction();
|
||||||
explicit CMutableTransaction(const CTransaction& tx);
|
explicit CMutableTransaction(const CTransaction& tx);
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
|
|
|
@ -1514,8 +1514,8 @@ BOOST_AUTO_TEST_CASE(bitcoinconsensus_verify_script_returns_true)
|
||||||
CScriptWitness wit;
|
CScriptWitness wit;
|
||||||
|
|
||||||
scriptPubKey << OP_1;
|
scriptPubKey << OP_1;
|
||||||
CTransaction creditTx = BuildCreditingTransaction(scriptPubKey, 1);
|
CTransaction creditTx{BuildCreditingTransaction(scriptPubKey, 1)};
|
||||||
CTransaction spendTx = BuildSpendingTransaction(scriptSig, wit, creditTx);
|
CTransaction spendTx{BuildSpendingTransaction(scriptSig, wit, creditTx)};
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << spendTx;
|
stream << spendTx;
|
||||||
|
@ -1537,8 +1537,8 @@ BOOST_AUTO_TEST_CASE(bitcoinconsensus_verify_script_tx_index_err)
|
||||||
CScriptWitness wit;
|
CScriptWitness wit;
|
||||||
|
|
||||||
scriptPubKey << OP_EQUAL;
|
scriptPubKey << OP_EQUAL;
|
||||||
CTransaction creditTx = BuildCreditingTransaction(scriptPubKey, 1);
|
CTransaction creditTx{BuildCreditingTransaction(scriptPubKey, 1)};
|
||||||
CTransaction spendTx = BuildSpendingTransaction(scriptSig, wit, creditTx);
|
CTransaction spendTx{BuildSpendingTransaction(scriptSig, wit, creditTx)};
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << spendTx;
|
stream << spendTx;
|
||||||
|
@ -1560,8 +1560,8 @@ BOOST_AUTO_TEST_CASE(bitcoinconsensus_verify_script_tx_size)
|
||||||
CScriptWitness wit;
|
CScriptWitness wit;
|
||||||
|
|
||||||
scriptPubKey << OP_EQUAL;
|
scriptPubKey << OP_EQUAL;
|
||||||
CTransaction creditTx = BuildCreditingTransaction(scriptPubKey, 1);
|
CTransaction creditTx{BuildCreditingTransaction(scriptPubKey, 1)};
|
||||||
CTransaction spendTx = BuildSpendingTransaction(scriptSig, wit, creditTx);
|
CTransaction spendTx{BuildSpendingTransaction(scriptSig, wit, creditTx)};
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << spendTx;
|
stream << spendTx;
|
||||||
|
@ -1583,8 +1583,8 @@ BOOST_AUTO_TEST_CASE(bitcoinconsensus_verify_script_tx_serialization)
|
||||||
CScriptWitness wit;
|
CScriptWitness wit;
|
||||||
|
|
||||||
scriptPubKey << OP_EQUAL;
|
scriptPubKey << OP_EQUAL;
|
||||||
CTransaction creditTx = BuildCreditingTransaction(scriptPubKey, 1);
|
CTransaction creditTx{BuildCreditingTransaction(scriptPubKey, 1)};
|
||||||
CTransaction spendTx = BuildSpendingTransaction(scriptSig, wit, creditTx);
|
CTransaction spendTx{BuildSpendingTransaction(scriptSig, wit, creditTx)};
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << 0xffffffff;
|
stream << 0xffffffff;
|
||||||
|
@ -1606,8 +1606,8 @@ BOOST_AUTO_TEST_CASE(bitcoinconsensus_verify_script_amount_required_err)
|
||||||
CScriptWitness wit;
|
CScriptWitness wit;
|
||||||
|
|
||||||
scriptPubKey << OP_EQUAL;
|
scriptPubKey << OP_EQUAL;
|
||||||
CTransaction creditTx = BuildCreditingTransaction(scriptPubKey, 1);
|
CTransaction creditTx{BuildCreditingTransaction(scriptPubKey, 1)};
|
||||||
CTransaction spendTx = BuildSpendingTransaction(scriptSig, wit, creditTx);
|
CTransaction spendTx{BuildSpendingTransaction(scriptSig, wit, creditTx)};
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << spendTx;
|
stream << spendTx;
|
||||||
|
@ -1629,8 +1629,8 @@ BOOST_AUTO_TEST_CASE(bitcoinconsensus_verify_script_invalid_flags)
|
||||||
CScriptWitness wit;
|
CScriptWitness wit;
|
||||||
|
|
||||||
scriptPubKey << OP_EQUAL;
|
scriptPubKey << OP_EQUAL;
|
||||||
CTransaction creditTx = BuildCreditingTransaction(scriptPubKey, 1);
|
CTransaction creditTx{BuildCreditingTransaction(scriptPubKey, 1)};
|
||||||
CTransaction spendTx = BuildSpendingTransaction(scriptSig, wit, creditTx);
|
CTransaction spendTx{BuildSpendingTransaction(scriptSig, wit, creditTx)};
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << spendTx;
|
stream << spendTx;
|
||||||
|
|
Loading…
Add table
Reference in a new issue