@@ -92,7 +92,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
9292 // Don't directly remove the transaction here -- doing so would
9393 // invalidate iterators in cachedDescendants. Mark it for removal
9494 // by inserting into descendants_to_remove.
95- if (descendant.GetCountWithAncestors () > uint64_t (m_limits. ancestor_count ) || descendant.GetSizeWithAncestors () > m_limits .ancestor_size_vbytes ) {
95+ if (descendant.GetCountWithAncestors () > uint64_t (m_opts. limits . ancestor_count ) || descendant.GetSizeWithAncestors () > m_opts. limits .ancestor_size_vbytes ) {
9696 descendants_to_remove.insert (descendant.GetTx ().GetHash ());
9797 }
9898 }
@@ -203,14 +203,14 @@ util::Result<void> CTxMemPool::CheckPackageLimits(const Package& package,
203203 size_t pack_count = package.size ();
204204
205205 // Package itself is busting mempool limits; should be rejected even if no staged_ancestors exist
206- if (pack_count > static_cast <uint64_t >(m_limits .ancestor_count )) {
207- return util::Error{Untranslated (strprintf (" package count %u exceeds ancestor count limit [limit: %u]" , pack_count, m_limits .ancestor_count ))};
208- } else if (pack_count > static_cast <uint64_t >(m_limits .descendant_count )) {
209- return util::Error{Untranslated (strprintf (" package count %u exceeds descendant count limit [limit: %u]" , pack_count, m_limits .descendant_count ))};
210- } else if (total_vsize > m_limits .ancestor_size_vbytes ) {
211- return util::Error{Untranslated (strprintf (" package size %u exceeds ancestor size limit [limit: %u]" , total_vsize, m_limits .ancestor_size_vbytes ))};
212- } else if (total_vsize > m_limits .descendant_size_vbytes ) {
213- return util::Error{Untranslated (strprintf (" package size %u exceeds descendant size limit [limit: %u]" , total_vsize, m_limits .descendant_size_vbytes ))};
206+ if (pack_count > static_cast <uint64_t >(m_opts. limits .ancestor_count )) {
207+ return util::Error{Untranslated (strprintf (" package count %u exceeds ancestor count limit [limit: %u]" , pack_count, m_opts. limits .ancestor_count ))};
208+ } else if (pack_count > static_cast <uint64_t >(m_opts. limits .descendant_count )) {
209+ return util::Error{Untranslated (strprintf (" package count %u exceeds descendant count limit [limit: %u]" , pack_count, m_opts. limits .descendant_count ))};
210+ } else if (total_vsize > m_opts. limits .ancestor_size_vbytes ) {
211+ return util::Error{Untranslated (strprintf (" package size %u exceeds ancestor size limit [limit: %u]" , total_vsize, m_opts. limits .ancestor_size_vbytes ))};
212+ } else if (total_vsize > m_opts. limits .descendant_size_vbytes ) {
213+ return util::Error{Untranslated (strprintf (" package size %u exceeds descendant size limit [limit: %u]" , total_vsize, m_opts. limits .descendant_size_vbytes ))};
214214 }
215215
216216 CTxMemPoolEntry::Parents staged_ancestors;
@@ -219,8 +219,8 @@ util::Result<void> CTxMemPool::CheckPackageLimits(const Package& package,
219219 std::optional<txiter> piter = GetIter (input.prevout .hash );
220220 if (piter) {
221221 staged_ancestors.insert (**piter);
222- if (staged_ancestors.size () + package.size () > static_cast <uint64_t >(m_limits .ancestor_count )) {
223- return util::Error{Untranslated (strprintf (" too many unconfirmed parents [limit: %u]" , m_limits .ancestor_count ))};
222+ if (staged_ancestors.size () + package.size () > static_cast <uint64_t >(m_opts. limits .ancestor_count )) {
223+ return util::Error{Untranslated (strprintf (" too many unconfirmed parents [limit: %u]" , m_opts. limits .ancestor_count ))};
224224 }
225225 }
226226 }
@@ -229,7 +229,7 @@ util::Result<void> CTxMemPool::CheckPackageLimits(const Package& package,
229229 // considered together must be within limits even if they are not interdependent. This may be
230230 // stricter than the limits for each individual transaction.
231231 const auto ancestors{CalculateAncestorsAndCheckLimits (total_vsize, package.size (),
232- staged_ancestors, m_limits )};
232+ staged_ancestors, m_opts. limits )};
233233 // It's possible to overestimate the ancestor/descendant totals.
234234 if (!ancestors.has_value ()) return util::Error{Untranslated (" possibly " + util::ErrorString (ancestors).original )};
235235 return {};
@@ -396,19 +396,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int32_t modifySize, CAmount modifyFee,
396396}
397397
398398CTxMemPool::CTxMemPool (const Options& opts)
399- : m_check_ratio{opts.check_ratio },
400- m_max_size_bytes{opts.max_size_bytes },
401- m_expiry{opts.expiry },
402- m_incremental_relay_feerate{opts.incremental_relay_feerate },
403- m_min_relay_feerate{opts.min_relay_feerate },
404- m_dust_relay_feerate{opts.dust_relay_feerate },
405- m_permit_bare_multisig{opts.permit_bare_multisig },
406- m_max_datacarrier_bytes{opts.max_datacarrier_bytes },
407- m_require_standard{opts.require_standard },
408- m_full_rbf{opts.full_rbf },
409- m_persist_v1_dat{opts.persist_v1_dat },
410- m_limits{opts.limits },
411- m_signals{opts.signals }
399+ : m_opts{opts}
412400{
413401}
414402
@@ -489,12 +477,12 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
489477 // even if not directly reported below.
490478 uint64_t mempool_sequence = GetAndIncrementSequence ();
491479
492- if (reason != MemPoolRemovalReason::BLOCK && m_signals ) {
480+ if (reason != MemPoolRemovalReason::BLOCK && m_opts. signals ) {
493481 // Notify clients that a transaction has been removed from the mempool
494482 // for any reason except being included in a block. Clients interested
495483 // in transactions included in blocks can subscribe to the BlockConnected
496484 // notification.
497- m_signals ->TransactionRemovedFromMempool (it->GetSharedTx (), reason, mempool_sequence);
485+ m_opts. signals ->TransactionRemovedFromMempool (it->GetSharedTx (), reason, mempool_sequence);
498486 }
499487 TRACE5 (mempool, removed,
500488 it->GetTx ().GetHash ().data (),
@@ -645,18 +633,18 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
645633 removeConflicts (*tx);
646634 ClearPrioritisation (tx->GetHash ());
647635 }
648- if (m_signals ) {
649- m_signals ->MempoolTransactionsRemovedForBlock (txs_removed_for_block, nBlockHeight);
636+ if (m_opts. signals ) {
637+ m_opts. signals ->MempoolTransactionsRemovedForBlock (txs_removed_for_block, nBlockHeight);
650638 }
651639 lastRollingFeeUpdate = GetTime ();
652640 blockSinceLastRollingFeeBump = true ;
653641}
654642
655643void CTxMemPool::check (const CCoinsViewCache& active_coins_tip, int64_t spendheight) const
656644{
657- if (m_check_ratio == 0 ) return ;
645+ if (m_opts. check_ratio == 0 ) return ;
658646
659- if (GetRand (m_check_ratio ) >= 1 ) return ;
647+ if (GetRand (m_opts. check_ratio ) >= 1 ) return ;
660648
661649 AssertLockHeld (::cs_main);
662650 LOCK (cs);
@@ -1108,12 +1096,12 @@ CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
11081096 rollingMinimumFeeRate = rollingMinimumFeeRate / pow (2.0 , (time - lastRollingFeeUpdate) / halflife);
11091097 lastRollingFeeUpdate = time;
11101098
1111- if (rollingMinimumFeeRate < (double )m_incremental_relay_feerate .GetFeePerK () / 2 ) {
1099+ if (rollingMinimumFeeRate < (double )m_opts. incremental_relay_feerate .GetFeePerK () / 2 ) {
11121100 rollingMinimumFeeRate = 0 ;
11131101 return CFeeRate (0 );
11141102 }
11151103 }
1116- return std::max (CFeeRate (llround (rollingMinimumFeeRate)), m_incremental_relay_feerate );
1104+ return std::max (CFeeRate (llround (rollingMinimumFeeRate)), m_opts. incremental_relay_feerate );
11171105}
11181106
11191107void CTxMemPool::trackPackageRemoved (const CFeeRate& rate) {
@@ -1137,7 +1125,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpends
11371125 // to have 0 fee). This way, we don't allow txn to enter mempool with feerate
11381126 // equal to txn which were removed with no block in between.
11391127 CFeeRate removed (it->GetModFeesWithDescendants (), it->GetSizeWithDescendants ());
1140- removed += m_incremental_relay_feerate ;
1128+ removed += m_opts. incremental_relay_feerate ;
11411129 trackPackageRemoved (removed);
11421130 maxFeeRateRemoved = std::max (maxFeeRateRemoved, removed);
11431131
0 commit comments