@@ -173,7 +173,6 @@ MiniMiner::MiniMiner(const std::vector<MiniMinerMempoolEntry>& manual_entries,
173173 SanityCheck ();
174174}
175175
176-
177176// Compare by min(ancestor feerate, individual feerate), then iterator
178177//
179178// Under the ancestor-based mining approach, high-feerate children can pay for parents, but high-feerate
@@ -253,8 +252,9 @@ void MiniMiner::SanityCheck() const
253252 [&](const auto & txid){return m_entries_by_txid.find (txid) == m_entries_by_txid.end ();}));
254253}
255254
256- void MiniMiner::BuildMockTemplate (const CFeeRate& target_feerate)
255+ void MiniMiner::BuildMockTemplate (std::optional< CFeeRate> target_feerate)
257256{
257+ const auto num_txns{m_entries_by_txid.size ()};
258258 while (!m_entries_by_txid.empty ()) {
259259 // Sort again, since transaction removal may change some m_entries' ancestor feerates.
260260 std::sort (m_entries.begin (), m_entries.end (), AncestorFeerateComparator ());
@@ -265,7 +265,8 @@ void MiniMiner::BuildMockTemplate(const CFeeRate& target_feerate)
265265 const auto ancestor_package_size = (*best_iter)->second .GetSizeWithAncestors ();
266266 const auto ancestor_package_fee = (*best_iter)->second .GetModFeesWithAncestors ();
267267 // Stop here. Everything that didn't "make it into the block" has bumpfee.
268- if (ancestor_package_fee < target_feerate.GetFee (ancestor_package_size)) {
268+ if (target_feerate.has_value () &&
269+ ancestor_package_fee < target_feerate->GetFee (ancestor_package_size)) {
269270 break ;
270271 }
271272
@@ -292,7 +293,11 @@ void MiniMiner::BuildMockTemplate(const CFeeRate& target_feerate)
292293 DeleteAncestorPackage (ancestors);
293294 SanityCheck ();
294295 }
295- Assume (m_in_block.empty () || m_total_fees >= target_feerate.GetFee (m_total_vsize));
296+ if (!target_feerate.has_value ()) {
297+ Assume (m_in_block.size () == num_txns);
298+ } else {
299+ Assume (m_in_block.empty () || m_total_fees >= target_feerate->GetFee (m_total_vsize));
300+ }
296301 // Do not try to continue building the block template with a different feerate.
297302 m_ready_to_calculate = false ;
298303}
0 commit comments