Skip to content

Commit 37495e0

Browse files
committed
Reorder C{,Mutable}Transaction for better packing
1 parent 479afa0 commit 37495e0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/primitives/transaction.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ std::string CTxOut::ToString() const
5555
}
5656

5757
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {}
58-
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime) {}
58+
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime) {}
5959

6060
uint256 CMutableTransaction::GetHash() const
6161
{
@@ -76,9 +76,9 @@ uint256 CTransaction::GetWitnessHash() const
7676
}
7777

7878
/* For backward compatibility, the hash is initialized to 0. TODO: remove the need for this default constructor entirely. */
79-
CTransaction::CTransaction() : nVersion(CTransaction::CURRENT_VERSION), vin(), vout(), nLockTime(0), hash() {}
80-
CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), hash(ComputeHash()) {}
81-
CTransaction::CTransaction(CMutableTransaction &&tx) : nVersion(tx.nVersion), vin(std::move(tx.vin)), vout(std::move(tx.vout)), nLockTime(tx.nLockTime), hash(ComputeHash()) {}
79+
CTransaction::CTransaction() : vin(), vout(), nVersion(CTransaction::CURRENT_VERSION), nLockTime(0), hash() {}
80+
CTransaction::CTransaction(const CMutableTransaction &tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash(ComputeHash()) {}
81+
CTransaction::CTransaction(CMutableTransaction &&tx) : vin(std::move(tx.vin)), vout(std::move(tx.vout)), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash(ComputeHash()) {}
8282

8383
CAmount CTransaction::GetValueOut() const
8484
{

src/primitives/transaction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ class CTransaction
279279
// actually immutable; deserialization and assignment are implemented,
280280
// and bypass the constness. This is safe, as they update the entire
281281
// structure, including the hash.
282-
const int32_t nVersion;
283282
const std::vector<CTxIn> vin;
284283
const std::vector<CTxOut> vout;
284+
const int32_t nVersion;
285285
const uint32_t nLockTime;
286286

287287
private:
@@ -362,9 +362,9 @@ class CTransaction
362362
/** A mutable version of CTransaction. */
363363
struct CMutableTransaction
364364
{
365-
int32_t nVersion;
366365
std::vector<CTxIn> vin;
367366
std::vector<CTxOut> vout;
367+
int32_t nVersion;
368368
uint32_t nLockTime;
369369

370370
CMutableTransaction();

0 commit comments

Comments
 (0)