14
14
#include < numeric>
15
15
#include < vector>
16
16
17
- /* * Helper for PackageV3Checks : Returns a vector containing the indices of transactions (within
17
+ /* * Helper for PackageTRUCChecks : Returns a vector containing the indices of transactions (within
18
18
* package) that are direct parents of ptx. */
19
19
std::vector<size_t > FindInPackageParents (const Package& package, const CTransactionRef& ptx)
20
20
{
@@ -37,7 +37,7 @@ std::vector<size_t> FindInPackageParents(const Package& package, const CTransact
37
37
return in_package_parents;
38
38
}
39
39
40
- /* * Helper for PackageV3Checks , storing info for a mempool or package parent. */
40
+ /* * Helper for PackageTRUCChecks , storing info for a mempool or package parent. */
41
41
struct ParentInfo {
42
42
/* * Txid used to identify this parent by prevout */
43
43
const Txid& m_txid;
@@ -55,36 +55,36 @@ struct ParentInfo {
55
55
{}
56
56
};
57
57
58
- std::optional<std::string> PackageV3Checks (const CTransactionRef& ptx, int64_t vsize,
58
+ std::optional<std::string> PackageTRUCChecks (const CTransactionRef& ptx, int64_t vsize,
59
59
const Package& package,
60
60
const CTxMemPool::setEntries& mempool_ancestors)
61
61
{
62
62
// This function is specialized for these limits, and must be reimplemented if they ever change.
63
- static_assert (V3_ANCESTOR_LIMIT == 2 );
64
- static_assert (V3_DESCENDANT_LIMIT == 2 );
63
+ static_assert (TRUC_ANCESTOR_LIMIT == 2 );
64
+ static_assert (TRUC_DESCENDANT_LIMIT == 2 );
65
65
66
66
const auto in_package_parents{FindInPackageParents (package, ptx)};
67
67
68
68
// Now we have all ancestors, so we can start checking TRUC rules.
69
69
if (ptx->version == TRUC_VERSION) {
70
- // SingleV3Checks should have checked this already.
71
- if (!Assume (vsize <= V3_MAX_VSIZE )) {
70
+ // SingleTRUCChecks should have checked this already.
71
+ if (!Assume (vsize <= TRUC_MAX_VSIZE )) {
72
72
return strprintf (" v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
73
- ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, V3_MAX_VSIZE );
73
+ ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, TRUC_MAX_VSIZE );
74
74
}
75
75
76
- if (mempool_ancestors.size () + in_package_parents.size () + 1 > V3_ANCESTOR_LIMIT ) {
76
+ if (mempool_ancestors.size () + in_package_parents.size () + 1 > TRUC_ANCESTOR_LIMIT ) {
77
77
return strprintf (" tx %s (wtxid=%s) would have too many ancestors" ,
78
78
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString ());
79
79
}
80
80
81
81
const bool has_parent{mempool_ancestors.size () + in_package_parents.size () > 0 };
82
82
if (has_parent) {
83
83
// A TRUC child cannot be too large.
84
- if (vsize > V3_CHILD_MAX_VSIZE ) {
84
+ if (vsize > TRUC_CHILD_MAX_VSIZE ) {
85
85
return strprintf (" v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
86
86
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (),
87
- vsize, V3_CHILD_MAX_VSIZE );
87
+ vsize, TRUC_CHILD_MAX_VSIZE );
88
88
}
89
89
90
90
// Exactly 1 parent exists, either in mempool or package. Find it.
@@ -118,7 +118,7 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
118
118
119
119
for (auto & input : package_tx->vin ) {
120
120
// Fail if we find another tx with the same parent. We don't check whether the
121
- // sibling is to-be-replaced (done in SingleV3Checks ) because these transactions
121
+ // sibling is to-be-replaced (done in SingleTRUCChecks ) because these transactions
122
122
// are within the same package.
123
123
if (input.prevout .hash == parent_info.m_txid ) {
124
124
return strprintf (" tx %s (wtxid=%s) would exceed descendant count limit" ,
@@ -161,7 +161,7 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
161
161
return std::nullopt;
162
162
}
163
163
164
- std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks (const CTransactionRef& ptx,
164
+ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks (const CTransactionRef& ptx,
165
165
const CTxMemPool::setEntries& mempool_ancestors,
166
166
const std::set<Txid>& direct_conflicts,
167
167
int64_t vsize)
@@ -182,20 +182,20 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
182
182
}
183
183
184
184
// This function is specialized for these limits, and must be reimplemented if they ever change.
185
- static_assert (V3_ANCESTOR_LIMIT == 2 );
186
- static_assert (V3_DESCENDANT_LIMIT == 2 );
185
+ static_assert (TRUC_ANCESTOR_LIMIT == 2 );
186
+ static_assert (TRUC_DESCENDANT_LIMIT == 2 );
187
187
188
188
// The rest of the rules only apply to transactions with version=3.
189
189
if (ptx->version != TRUC_VERSION) return std::nullopt;
190
190
191
- if (vsize > V3_MAX_VSIZE ) {
191
+ if (vsize > TRUC_MAX_VSIZE ) {
192
192
return std::make_pair (strprintf (" v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
193
- ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, V3_MAX_VSIZE ),
193
+ ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, TRUC_MAX_VSIZE ),
194
194
nullptr );
195
195
}
196
196
197
- // Check that V3_ANCESTOR_LIMIT would not be violated.
198
- if (mempool_ancestors.size () + 1 > V3_ANCESTOR_LIMIT ) {
197
+ // Check that TRUC_ANCESTOR_LIMIT would not be violated.
198
+ if (mempool_ancestors.size () + 1 > TRUC_ANCESTOR_LIMIT ) {
199
199
return std::make_pair (strprintf (" tx %s (wtxid=%s) would have too many ancestors" ,
200
200
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString ()),
201
201
nullptr );
@@ -204,9 +204,9 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
204
204
// Remaining checks only pertain to transactions with unconfirmed ancestors.
205
205
if (mempool_ancestors.size () > 0 ) {
206
206
// If this transaction spends TRUC parents, it cannot be too large.
207
- if (vsize > V3_CHILD_MAX_VSIZE ) {
207
+ if (vsize > TRUC_CHILD_MAX_VSIZE ) {
208
208
return std::make_pair (strprintf (" v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
209
- ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, V3_CHILD_MAX_VSIZE ),
209
+ ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, TRUC_CHILD_MAX_VSIZE ),
210
210
nullptr );
211
211
}
212
212
@@ -222,7 +222,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
222
222
const bool child_will_be_replaced = !children.empty () &&
223
223
std::any_of (children.cbegin (), children.cend (),
224
224
[&direct_conflicts](const CTxMemPoolEntry& child){return direct_conflicts.count (child.GetTx ().GetHash ()) > 0 ;});
225
- if (parent_entry->GetCountWithDescendants () + 1 > V3_DESCENDANT_LIMIT && !child_will_be_replaced) {
225
+ if (parent_entry->GetCountWithDescendants () + 1 > TRUC_DESCENDANT_LIMIT && !child_will_be_replaced) {
226
226
// Allow sibling eviction for TRUC transaction: if another child already exists, even if
227
227
// we don't conflict inputs with it, consider evicting it under RBF rules. We rely on TRUC rules
228
228
// only permitting 1 descendant, as otherwise we would need to have logic for deciding
0 commit comments