1414#include < numeric>
1515#include < vector>
1616
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
1818 * package) that are direct parents of ptx. */
1919std::vector<size_t > FindInPackageParents (const Package& package, const CTransactionRef& ptx)
2020{
@@ -37,7 +37,7 @@ std::vector<size_t> FindInPackageParents(const Package& package, const CTransact
3737 return in_package_parents;
3838}
3939
40- /* * Helper for PackageV3Checks , storing info for a mempool or package parent. */
40+ /* * Helper for PackageTRUCChecks , storing info for a mempool or package parent. */
4141struct ParentInfo {
4242 /* * Txid used to identify this parent by prevout */
4343 const Txid& m_txid;
@@ -55,36 +55,36 @@ struct ParentInfo {
5555 {}
5656};
5757
58- std::optional<std::string> PackageV3Checks (const CTransactionRef& ptx, int64_t vsize,
58+ std::optional<std::string> PackageTRUCChecks (const CTransactionRef& ptx, int64_t vsize,
5959 const Package& package,
6060 const CTxMemPool::setEntries& mempool_ancestors)
6161{
6262 // 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 );
6565
6666 const auto in_package_parents{FindInPackageParents (package, ptx)};
6767
6868 // Now we have all ancestors, so we can start checking TRUC rules.
6969 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 )) {
7272 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 );
7474 }
7575
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 ) {
7777 return strprintf (" tx %s (wtxid=%s) would have too many ancestors" ,
7878 ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString ());
7979 }
8080
8181 const bool has_parent{mempool_ancestors.size () + in_package_parents.size () > 0 };
8282 if (has_parent) {
8383 // A TRUC child cannot be too large.
84- if (vsize > V3_CHILD_MAX_VSIZE ) {
84+ if (vsize > TRUC_CHILD_MAX_VSIZE ) {
8585 return strprintf (" v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
8686 ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (),
87- vsize, V3_CHILD_MAX_VSIZE );
87+ vsize, TRUC_CHILD_MAX_VSIZE );
8888 }
8989
9090 // 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
118118
119119 for (auto & input : package_tx->vin ) {
120120 // 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
122122 // are within the same package.
123123 if (input.prevout .hash == parent_info.m_txid ) {
124124 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
161161 return std::nullopt ;
162162}
163163
164- std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks (const CTransactionRef& ptx,
164+ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks (const CTransactionRef& ptx,
165165 const CTxMemPool::setEntries& mempool_ancestors,
166166 const std::set<Txid>& direct_conflicts,
167167 int64_t vsize)
@@ -182,20 +182,20 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
182182 }
183183
184184 // 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 );
187187
188188 // The rest of the rules only apply to transactions with version=3.
189189 if (ptx->version != TRUC_VERSION) return std::nullopt ;
190190
191- if (vsize > V3_MAX_VSIZE ) {
191+ if (vsize > TRUC_MAX_VSIZE ) {
192192 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 ),
194194 nullptr );
195195 }
196196
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 ) {
199199 return std::make_pair (strprintf (" tx %s (wtxid=%s) would have too many ancestors" ,
200200 ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString ()),
201201 nullptr );
@@ -204,9 +204,9 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
204204 // Remaining checks only pertain to transactions with unconfirmed ancestors.
205205 if (mempool_ancestors.size () > 0 ) {
206206 // 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 ) {
208208 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 ),
210210 nullptr );
211211 }
212212
@@ -222,7 +222,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
222222 const bool child_will_be_replaced = !children.empty () &&
223223 std::any_of (children.cbegin (), children.cend (),
224224 [&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) {
226226 // Allow sibling eviction for TRUC transaction: if another child already exists, even if
227227 // we don't conflict inputs with it, consider evicting it under RBF rules. We rely on TRUC rules
228228 // only permitting 1 descendant, as otherwise we would need to have logic for deciding
0 commit comments