@@ -173,7 +173,6 @@ MiniMiner::MiniMiner(const std::vector<MiniMinerMempoolEntry>& manual_entries,
173
173
SanityCheck ();
174
174
}
175
175
176
-
177
176
// Compare by min(ancestor feerate, individual feerate), then iterator
178
177
//
179
178
// Under the ancestor-based mining approach, high-feerate children can pay for parents, but high-feerate
@@ -253,8 +252,9 @@ void MiniMiner::SanityCheck() const
253
252
[&](const auto & txid){return m_entries_by_txid.find (txid) == m_entries_by_txid.end ();}));
254
253
}
255
254
256
- void MiniMiner::BuildMockTemplate (const CFeeRate& target_feerate)
255
+ void MiniMiner::BuildMockTemplate (std::optional< CFeeRate> target_feerate)
257
256
{
257
+ const auto num_txns{m_entries_by_txid.size ()};
258
258
while (!m_entries_by_txid.empty ()) {
259
259
// Sort again, since transaction removal may change some m_entries' ancestor feerates.
260
260
std::sort (m_entries.begin (), m_entries.end (), AncestorFeerateComparator ());
@@ -265,7 +265,8 @@ void MiniMiner::BuildMockTemplate(const CFeeRate& target_feerate)
265
265
const auto ancestor_package_size = (*best_iter)->second .GetSizeWithAncestors ();
266
266
const auto ancestor_package_fee = (*best_iter)->second .GetModFeesWithAncestors ();
267
267
// 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)) {
269
270
break ;
270
271
}
271
272
@@ -292,7 +293,11 @@ void MiniMiner::BuildMockTemplate(const CFeeRate& target_feerate)
292
293
DeleteAncestorPackage (ancestors);
293
294
SanityCheck ();
294
295
}
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
+ }
296
301
// Do not try to continue building the block template with a different feerate.
297
302
m_ready_to_calculate = false ;
298
303
}
0 commit comments