@@ -187,10 +187,7 @@ bool CTxMemPool::CalculateAncestorsAndCheckLimits(size_t entry_size,
187187 size_t entry_count,
188188 setEntries& setAncestors,
189189 CTxMemPoolEntry::Parents& staged_ancestors,
190- uint64_t limitAncestorCount,
191- uint64_t limitAncestorSize,
192- uint64_t limitDescendantCount,
193- uint64_t limitDescendantSize,
190+ const Limits& limits,
194191 std::string &errString) const
195192{
196193 size_t totalSizeWithAncestors = entry_size;
@@ -203,14 +200,14 @@ bool CTxMemPool::CalculateAncestorsAndCheckLimits(size_t entry_size,
203200 staged_ancestors.erase (stage);
204201 totalSizeWithAncestors += stageit->GetTxSize ();
205202
206- if (stageit->GetSizeWithDescendants () + entry_size > limitDescendantSize ) {
207- errString = strprintf (" exceeds descendant size limit for tx %s [limit: %u]" , stageit->GetTx ().GetHash ().ToString (), limitDescendantSize );
203+ if (stageit->GetSizeWithDescendants () + entry_size > static_cast < uint64_t >(limits. descendant_size_vbytes ) ) {
204+ errString = strprintf (" exceeds descendant size limit for tx %s [limit: %u]" , stageit->GetTx ().GetHash ().ToString (), limits. descendant_size_vbytes );
208205 return false ;
209- } else if (stageit->GetCountWithDescendants () + entry_count > limitDescendantCount ) {
210- errString = strprintf (" too many descendants for tx %s [limit: %u]" , stageit->GetTx ().GetHash ().ToString (), limitDescendantCount );
206+ } else if (stageit->GetCountWithDescendants () + entry_count > static_cast < uint64_t >(limits. descendant_count ) ) {
207+ errString = strprintf (" too many descendants for tx %s [limit: %u]" , stageit->GetTx ().GetHash ().ToString (), limits. descendant_count );
211208 return false ;
212- } else if (totalSizeWithAncestors > limitAncestorSize ) {
213- errString = strprintf (" exceeds ancestor size limit [limit: %u]" , limitAncestorSize );
209+ } else if (totalSizeWithAncestors > static_cast < uint64_t >(limits. ancestor_size_vbytes ) ) {
210+ errString = strprintf (" exceeds ancestor size limit [limit: %u]" , limits. ancestor_size_vbytes );
214211 return false ;
215212 }
216213
@@ -222,8 +219,8 @@ bool CTxMemPool::CalculateAncestorsAndCheckLimits(size_t entry_size,
222219 if (setAncestors.count (parent_it) == 0 ) {
223220 staged_ancestors.insert (parent);
224221 }
225- if (staged_ancestors.size () + setAncestors.size () + entry_count > limitAncestorCount ) {
226- errString = strprintf (" too many unconfirmed ancestors [limit: %u]" , limitAncestorCount );
222+ if (staged_ancestors.size () + setAncestors.size () + entry_count > static_cast < uint64_t >(limits. ancestor_count ) ) {
223+ errString = strprintf (" too many unconfirmed ancestors [limit: %u]" , limits. ancestor_count );
227224 return false ;
228225 }
229226 }
@@ -233,10 +230,7 @@ bool CTxMemPool::CalculateAncestorsAndCheckLimits(size_t entry_size,
233230}
234231
235232bool CTxMemPool::CheckPackageLimits (const Package& package,
236- uint64_t limitAncestorCount,
237- uint64_t limitAncestorSize,
238- uint64_t limitDescendantCount,
239- uint64_t limitDescendantSize,
233+ const Limits& limits,
240234 std::string &errString) const
241235{
242236 CTxMemPoolEntry::Parents staged_ancestors;
@@ -247,8 +241,8 @@ bool CTxMemPool::CheckPackageLimits(const Package& package,
247241 std::optional<txiter> piter = GetIter (input.prevout .hash );
248242 if (piter) {
249243 staged_ancestors.insert (**piter);
250- if (staged_ancestors.size () + package.size () > limitAncestorCount ) {
251- errString = strprintf (" too many unconfirmed parents [limit: %u]" , limitAncestorCount );
244+ if (staged_ancestors.size () + package.size () > static_cast < uint64_t >(limits. ancestor_count ) ) {
245+ errString = strprintf (" too many unconfirmed parents [limit: %u]" , limits. ancestor_count );
252246 return false ;
253247 }
254248 }
@@ -260,19 +254,15 @@ bool CTxMemPool::CheckPackageLimits(const Package& package,
260254 setEntries setAncestors;
261255 const auto ret = CalculateAncestorsAndCheckLimits (total_size, package.size (),
262256 setAncestors, staged_ancestors,
263- limitAncestorCount, limitAncestorSize,
264- limitDescendantCount, limitDescendantSize, errString);
257+ limits, errString);
265258 // It's possible to overestimate the ancestor/descendant totals.
266259 if (!ret) errString.insert (0 , " possibly " );
267260 return ret;
268261}
269262
270263bool CTxMemPool::CalculateMemPoolAncestors (const CTxMemPoolEntry &entry,
271264 setEntries &setAncestors,
272- uint64_t limitAncestorCount,
273- uint64_t limitAncestorSize,
274- uint64_t limitDescendantCount,
275- uint64_t limitDescendantSize,
265+ const Limits& limits,
276266 std::string &errString,
277267 bool fSearchForParents /* = true */ ) const
278268{
@@ -287,8 +277,8 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry,
287277 std::optional<txiter> piter = GetIter (tx.vin [i].prevout .hash );
288278 if (piter) {
289279 staged_ancestors.insert (**piter);
290- if (staged_ancestors.size () + 1 > limitAncestorCount ) {
291- errString = strprintf (" too many unconfirmed parents [limit: %u]" , limitAncestorCount );
280+ if (staged_ancestors.size () + 1 > static_cast < uint64_t >(limits. ancestor_count ) ) {
281+ errString = strprintf (" too many unconfirmed parents [limit: %u]" , limits. ancestor_count );
292282 return false ;
293283 }
294284 }
@@ -302,8 +292,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry,
302292
303293 return CalculateAncestorsAndCheckLimits (entry.GetTxSize (), /* entry_count=*/ 1 ,
304294 setAncestors, staged_ancestors,
305- limitAncestorCount, limitAncestorSize,
306- limitDescendantCount, limitDescendantSize, errString);
295+ limits, errString);
307296}
308297
309298void CTxMemPool::UpdateAncestorsOf (bool add, txiter it, setEntries &setAncestors)
@@ -347,7 +336,6 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
347336{
348337 // For each entry, walk back all ancestors and decrement size associated with this
349338 // transaction
350- const uint64_t nNoLimit = std::numeric_limits<uint64_t >::max ();
351339 if (updateDescendants) {
352340 // updateDescendants should be true whenever we're not recursively
353341 // removing a tx and all its descendants, eg when a transaction is
@@ -390,7 +378,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
390378 // mempool parents we'd calculate by searching, and it's important that
391379 // we use the cached notion of ancestor transactions as the set of
392380 // things to update for removal.
393- CalculateMemPoolAncestors (entry, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit , dummy, false );
381+ CalculateMemPoolAncestors (entry, setAncestors, Limits::NoLimits () , dummy, false );
394382 // Note that UpdateAncestorsOf severs the child links that point to
395383 // removeIt in the entries for the parents of removeIt.
396384 UpdateAncestorsOf (false , removeIt, setAncestors);
@@ -744,9 +732,8 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
744732 assert (std::equal (setParentCheck.begin (), setParentCheck.end (), it->GetMemPoolParentsConst ().begin (), comp));
745733 // Verify ancestor state is correct.
746734 setEntries setAncestors;
747- uint64_t nNoLimit = std::numeric_limits<uint64_t >::max ();
748735 std::string dummy;
749- CalculateMemPoolAncestors (*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit , dummy);
736+ CalculateMemPoolAncestors (*it, setAncestors, Limits::NoLimits () , dummy);
750737 uint64_t nCountCheck = setAncestors.size () + 1 ;
751738 uint64_t nSizeCheck = it->GetTxSize ();
752739 CAmount nFeesCheck = it->GetModifiedFee ();
@@ -908,9 +895,8 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
908895 mapTx.modify (it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee (nFeeDelta); });
909896 // Now update all ancestors' modified fees with descendants
910897 setEntries setAncestors;
911- uint64_t nNoLimit = std::numeric_limits<uint64_t >::max ();
912898 std::string dummy;
913- CalculateMemPoolAncestors (*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit , dummy, false );
899+ CalculateMemPoolAncestors (*it, setAncestors, Limits::NoLimits () , dummy, false );
914900 for (txiter ancestorIt : setAncestors) {
915901 mapTx.modify (ancestorIt, [=](CTxMemPoolEntry& e){ e.UpdateDescendantState (0 , nFeeDelta, 0 );});
916902 }
@@ -1049,9 +1035,8 @@ int CTxMemPool::Expire(std::chrono::seconds time)
10491035void CTxMemPool::addUnchecked (const CTxMemPoolEntry &entry, bool validFeeEstimate)
10501036{
10511037 setEntries setAncestors;
1052- uint64_t nNoLimit = std::numeric_limits<uint64_t >::max ();
10531038 std::string dummy;
1054- CalculateMemPoolAncestors (entry, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit , dummy);
1039+ CalculateMemPoolAncestors (entry, setAncestors, Limits::NoLimits () , dummy);
10551040 return addUnchecked (entry, setAncestors, validFeeEstimate);
10561041}
10571042
0 commit comments