aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/node/mini_miner.cpp13
-rw-r--r--src/node/mini_miner.h8
2 files changed, 14 insertions, 7 deletions
diff --git a/src/node/mini_miner.cpp b/src/node/mini_miner.cpp
index c7bb4a6a42..ea702ab734 100644
--- a/src/node/mini_miner.cpp
+++ b/src/node/mini_miner.cpp
@@ -173,7 +173,6 @@ MiniMiner::MiniMiner(const std::vector<MiniMinerMempoolEntry>& manual_entries,
SanityCheck();
}
-
// Compare by min(ancestor feerate, individual feerate), then iterator
//
// Under the ancestor-based mining approach, high-feerate children can pay for parents, but high-feerate
@@ -253,8 +252,9 @@ void MiniMiner::SanityCheck() const
[&](const auto& txid){return m_entries_by_txid.find(txid) == m_entries_by_txid.end();}));
}
-void MiniMiner::BuildMockTemplate(const CFeeRate& target_feerate)
+void MiniMiner::BuildMockTemplate(std::optional<CFeeRate> target_feerate)
{
+ const auto num_txns{m_entries_by_txid.size()};
while (!m_entries_by_txid.empty()) {
// Sort again, since transaction removal may change some m_entries' ancestor feerates.
std::sort(m_entries.begin(), m_entries.end(), AncestorFeerateComparator());
@@ -265,7 +265,8 @@ void MiniMiner::BuildMockTemplate(const CFeeRate& target_feerate)
const auto ancestor_package_size = (*best_iter)->second.GetSizeWithAncestors();
const auto ancestor_package_fee = (*best_iter)->second.GetModFeesWithAncestors();
// Stop here. Everything that didn't "make it into the block" has bumpfee.
- if (ancestor_package_fee < target_feerate.GetFee(ancestor_package_size)) {
+ if (target_feerate.has_value() &&
+ ancestor_package_fee < target_feerate->GetFee(ancestor_package_size)) {
break;
}
@@ -292,7 +293,11 @@ void MiniMiner::BuildMockTemplate(const CFeeRate& target_feerate)
DeleteAncestorPackage(ancestors);
SanityCheck();
}
- Assume(m_in_block.empty() || m_total_fees >= target_feerate.GetFee(m_total_vsize));
+ if (!target_feerate.has_value()) {
+ Assume(m_in_block.size() == num_txns);
+ } else {
+ Assume(m_in_block.empty() || m_total_fees >= target_feerate->GetFee(m_total_vsize));
+ }
// Do not try to continue building the block template with a different feerate.
m_ready_to_calculate = false;
}
diff --git a/src/node/mini_miner.h b/src/node/mini_miner.h
index f1713bc868..e0051f3364 100644
--- a/src/node/mini_miner.h
+++ b/src/node/mini_miner.h
@@ -84,7 +84,7 @@ class MiniMiner
// the same tx will have the same bumpfee. Excludes non-mempool transactions.
std::map<uint256, std::vector<COutPoint>> m_requested_outpoints_by_txid;
- // What we're trying to calculate.
+ // What we're trying to calculate. Outpoint to the fee needed to bring the transaction to the target feerate.
std::map<COutPoint, CAmount> m_bump_fees;
// The constructed block template
@@ -114,8 +114,9 @@ public:
/** Returns true if CalculateBumpFees may be called, false if not. */
bool IsReadyToCalculate() const { return m_ready_to_calculate; }
- /** Build a block template until the target feerate is hit. */
- void BuildMockTemplate(const CFeeRate& target_feerate);
+ /** Build a block template until the target feerate is hit. If target_feerate is not given,
+ * builds a block template until all transactions have been selected. */
+ void BuildMockTemplate(std::optional<CFeeRate> target_feerate);
/** Returns set of txids in the block template if one has been constructed. */
std::set<uint256> GetMockTemplateTxids() const { return m_in_block; }
@@ -149,6 +150,7 @@ public:
* not make it into the block to the target feerate. Returns the total bump fee, or std::nullopt
* if it cannot be calculated. */
std::optional<CAmount> CalculateTotalBumpFees(const CFeeRate& target_feerate);
+
};
} // namespace node