aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2023-10-31 08:51:20 +0000
committerglozow <gloriajzhao@gmail.com>2023-11-03 10:17:41 +0000
commite3b2e630b219ca15fe0b2640ca422712c86ac33d (patch)
tree3aa5183db8e2d4381f71d623aa034fef8a0aa81e /src
parent4aa98b79b266cd526efa577762b0bcfccbdeda11 (diff)
[refactor] change MiniMinerMempoolEntry ctor to take values, update includes
No behavior change. All we are doing is copying out these values before passing them into the ctor instead of within the ctor. This makes it possible to use the MiniMiner algorithms to analyze transactions that haven't been submitted to the mempool yet. It also iwyu's the mini_miner includes.
Diffstat (limited to 'src')
-rw-r--r--src/node/mini_miner.cpp12
-rw-r--r--src/node/mini_miner.h30
2 files changed, 32 insertions, 10 deletions
diff --git a/src/node/mini_miner.cpp b/src/node/mini_miner.cpp
index 2827242f96..95eac7a243 100644
--- a/src/node/mini_miner.cpp
+++ b/src/node/mini_miner.cpp
@@ -4,9 +4,14 @@
#include <node/mini_miner.h>
+#include <boost/multi_index/detail/hash_index_iterator.hpp>
+#include <boost/operators.hpp>
#include <consensus/amount.h>
#include <policy/feerate.h>
#include <primitives/transaction.h>
+#include <sync.h>
+#include <txmempool.h>
+#include <uint256.h>
#include <util/check.h>
#include <algorithm>
@@ -72,7 +77,12 @@ MiniMiner::MiniMiner(const CTxMemPool& mempool, const std::vector<COutPoint>& ou
// Add every entry to m_entries_by_txid and m_entries, except the ones that will be replaced.
for (const auto& txiter : cluster) {
if (!m_to_be_replaced.count(txiter->GetTx().GetHash())) {
- auto [mapiter, success] = m_entries_by_txid.emplace(txiter->GetTx().GetHash(), MiniMinerMempoolEntry(txiter));
+ auto [mapiter, success] = m_entries_by_txid.emplace(txiter->GetTx().GetHash(),
+ MiniMinerMempoolEntry{/*fee_self=*/txiter->GetModifiedFee(),
+ /*fee_ancestor=*/txiter->GetModFeesWithAncestors(),
+ /*vsize_self=*/txiter->GetTxSize(),
+ /*vsize_ancestor=*/txiter->GetSizeWithAncestors(),
+ /*tx_in=*/txiter->GetSharedTx()});
m_entries.push_back(mapiter);
} else {
auto outpoints_it = m_requested_outpoints_by_txid.find(txiter->GetTx().GetHash());
diff --git a/src/node/mini_miner.h b/src/node/mini_miner.h
index 9d9d66bf0b..ae26202965 100644
--- a/src/node/mini_miner.h
+++ b/src/node/mini_miner.h
@@ -5,33 +5,45 @@
#ifndef BITCOIN_NODE_MINI_MINER_H
#define BITCOIN_NODE_MINI_MINER_H
-#include <txmempool.h>
+#include <consensus/amount.h>
+#include <primitives/transaction.h>
+#include <uint256.h>
+#include <map>
#include <memory>
#include <optional>
+#include <set>
#include <stdint.h>
+#include <vector>
+
+class CFeeRate;
+class CTxMemPool;
namespace node {
// Container for tracking updates to ancestor feerate as we include ancestors in the "block"
class MiniMinerMempoolEntry
{
- const CAmount fee_individual;
const CTransactionRef tx;
const int64_t vsize_individual;
- CAmount fee_with_ancestors;
int64_t vsize_with_ancestors;
+ const CAmount fee_individual;
+ CAmount fee_with_ancestors;
// This class must be constructed while holding mempool.cs. After construction, the object's
// methods can be called without holding that lock.
public:
- explicit MiniMinerMempoolEntry(CTxMemPool::txiter entry) :
- fee_individual{entry->GetModifiedFee()},
- tx{entry->GetSharedTx()},
- vsize_individual(entry->GetTxSize()),
- fee_with_ancestors{entry->GetModFeesWithAncestors()},
- vsize_with_ancestors(entry->GetSizeWithAncestors())
+ explicit MiniMinerMempoolEntry(CAmount fee_self,
+ CAmount fee_ancestor,
+ int64_t vsize_self,
+ int64_t vsize_ancestor,
+ const CTransactionRef& tx_in):
+ tx{tx_in},
+ vsize_individual{vsize_self},
+ vsize_with_ancestors{vsize_ancestor},
+ fee_individual{fee_self},
+ fee_with_ancestors{fee_ancestor}
{ }
CAmount GetModifiedFee() const { return fee_individual; }