aboutsummaryrefslogtreecommitdiff
path: root/src/policy
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-01-26 15:27:13 -0500
committerAva Chow <github@achow101.com>2024-06-07 13:55:23 -0400
commit429ec1aaaaafab150f11e27fcf132a99b57c4fc7 (patch)
treee09999b341f124bf12712f5111d563a9003f1872 /src/policy
parent27e70f1f5be1f536f2314cd2ea42b4f80d927fbd (diff)
downloadbitcoin-429ec1aaaaafab150f11e27fcf132a99b57c4fc7.tar.xz
refactor: Rename CTransaction::nVersion to version
In order to ensure that the change of nVersion to a uint32_t in the previous commit has no effect, rename nVersion to version in this commit so that reviewers can easily spot if a spot was missed or if there is a check somewhere whose semantics have changed.
Diffstat (limited to 'src/policy')
-rw-r--r--src/policy/policy.cpp2
-rw-r--r--src/policy/policy.h2
-rw-r--r--src/policy/v3_policy.cpp24
-rw-r--r--src/policy/v3_policy.h4
4 files changed, 16 insertions, 16 deletions
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
index d8b4b907e4..e84a8428bf 100644
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -93,7 +93,7 @@ bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_
bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason)
{
- if (tx.nVersion > TX_MAX_STANDARD_VERSION || tx.nVersion < 1) {
+ if (tx.version > TX_MAX_STANDARD_VERSION || tx.version < 1) {
reason = "version";
return false;
}
diff --git a/src/policy/policy.h b/src/policy/policy.h
index 20d632183a..a82488a28c 100644
--- a/src/policy/policy.h
+++ b/src/policy/policy.h
@@ -131,7 +131,7 @@ bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_
// Changing the default transaction version requires a two step process: first
// adapting relay policy by bumping TX_MAX_STANDARD_VERSION, and then later
// allowing the new transaction version in the wallet/RPC.
-static constexpr decltype(CTransaction::nVersion) TX_MAX_STANDARD_VERSION{3};
+static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3};
/**
* Check for standard transaction types
diff --git a/src/policy/v3_policy.cpp b/src/policy/v3_policy.cpp
index 9151d97ac2..bcf0b2b236 100644
--- a/src/policy/v3_policy.cpp
+++ b/src/policy/v3_policy.cpp
@@ -43,13 +43,13 @@ struct ParentInfo {
const Txid& m_txid;
/** Wtxid used for debug string */
const Wtxid& m_wtxid;
- /** nVersion used to check inheritance of v3 and non-v3 */
- decltype(CTransaction::nVersion) m_version;
+ /** version used to check inheritance of v3 and non-v3 */
+ decltype(CTransaction::version) m_version;
/** If parent is in mempool, whether it has any descendants in mempool. */
bool m_has_mempool_descendant;
ParentInfo() = delete;
- ParentInfo(const Txid& txid, const Wtxid& wtxid, decltype(CTransaction::nVersion) version, bool has_mempool_descendant) :
+ ParentInfo(const Txid& txid, const Wtxid& wtxid, decltype(CTransaction::version) version, bool has_mempool_descendant) :
m_txid{txid}, m_wtxid{wtxid}, m_version{version},
m_has_mempool_descendant{has_mempool_descendant}
{}
@@ -66,7 +66,7 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
const auto in_package_parents{FindInPackageParents(package, ptx)};
// Now we have all ancestors, so we can start checking v3 rules.
- if (ptx->nVersion == TRUC_VERSION) {
+ if (ptx->version == TRUC_VERSION) {
// SingleV3Checks should have checked this already.
if (!Assume(vsize <= V3_MAX_VSIZE)) {
return strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
@@ -94,14 +94,14 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
Assume(mempool_parent->GetCountWithDescendants() == 1);
return ParentInfo{mempool_parent->GetTx().GetHash(),
mempool_parent->GetTx().GetWitnessHash(),
- mempool_parent->GetTx().nVersion,
+ mempool_parent->GetTx().version,
/*has_mempool_descendant=*/mempool_parent->GetCountWithDescendants() > 1};
} else {
auto& parent_index = in_package_parents.front();
auto& package_parent = package.at(parent_index);
return ParentInfo{package_parent->GetHash(),
package_parent->GetWitnessHash(),
- package_parent->nVersion,
+ package_parent->version,
/*has_mempool_descendant=*/false};
}
}();
@@ -146,14 +146,14 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
} else {
// Non-v3 transactions cannot have v3 parents.
for (auto it : mempool_ancestors) {
- if (it->GetTx().nVersion == TRUC_VERSION) {
+ if (it->GetTx().version == TRUC_VERSION) {
return strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
it->GetSharedTx()->GetHash().ToString(), it->GetSharedTx()->GetWitnessHash().ToString());
}
}
for (const auto& index: in_package_parents) {
- if (package.at(index)->nVersion == TRUC_VERSION) {
+ if (package.at(index)->version == TRUC_VERSION) {
return strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
ptx->GetHash().ToString(),
ptx->GetWitnessHash().ToString(),
@@ -172,12 +172,12 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
{
// Check v3 and non-v3 inheritance.
for (const auto& entry : mempool_ancestors) {
- if (ptx->nVersion != TRUC_VERSION && entry->GetTx().nVersion == TRUC_VERSION) {
+ if (ptx->version != TRUC_VERSION && entry->GetTx().version == TRUC_VERSION) {
return std::make_pair(strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
entry->GetSharedTx()->GetHash().ToString(), entry->GetSharedTx()->GetWitnessHash().ToString()),
nullptr);
- } else if (ptx->nVersion == TRUC_VERSION && entry->GetTx().nVersion != TRUC_VERSION) {
+ } else if (ptx->version == TRUC_VERSION && entry->GetTx().version != TRUC_VERSION) {
return std::make_pair(strprintf("v3 tx %s (wtxid=%s) cannot spend from non-v3 tx %s (wtxid=%s)",
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
entry->GetSharedTx()->GetHash().ToString(), entry->GetSharedTx()->GetWitnessHash().ToString()),
@@ -189,8 +189,8 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
static_assert(V3_ANCESTOR_LIMIT == 2);
static_assert(V3_DESCENDANT_LIMIT == 2);
- // The rest of the rules only apply to transactions with nVersion=3.
- if (ptx->nVersion != TRUC_VERSION) return std::nullopt;
+ // The rest of the rules only apply to transactions with version=3.
+ if (ptx->version != TRUC_VERSION) return std::nullopt;
if (vsize > V3_MAX_VSIZE) {
return std::make_pair(strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
diff --git a/src/policy/v3_policy.h b/src/policy/v3_policy.h
index 84dadd8719..90eaeda46f 100644
--- a/src/policy/v3_policy.h
+++ b/src/policy/v3_policy.h
@@ -15,9 +15,9 @@
#include <set>
#include <string>
-// This module enforces rules for BIP 431 TRUC transactions (with nVersion=3) which help make
+// This module enforces rules for BIP 431 TRUC transactions (with version=3) which help make
// RBF abilities more robust.
-static constexpr decltype(CTransaction::nVersion) TRUC_VERSION{3};
+static constexpr decltype(CTransaction::version) TRUC_VERSION{3};
// v3 only allows 1 parent and 1 child when unconfirmed.
/** Maximum number of transactions including an unconfirmed tx and its descendants. */