Skip to content

Commit 84e4ef8

Browse files
committed
[txdownload] add read-only reference to mempool
This will become necessary in later commits that query mempool. We also introduce the TxDownloadOptions in this commit to make the later diff easier to review.
1 parent af91834 commit 84e4ef8

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,7 @@ PeerManagerImpl::PeerManagerImpl(CConnman& connman, AddrMan& addrman,
20002000
m_banman(banman),
20012001
m_chainman(chainman),
20022002
m_mempool(pool),
2003+
m_txdownloadman(node::TxDownloadOptions{pool}),
20032004
m_warnings{warnings},
20042005
m_opts{opts}
20052006
{

src/node/txdownloadman.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010

1111
class CBlock;
1212
class CRollingBloomFilter;
13+
class CTxMemPool;
1314
class TxOrphanage;
1415
class TxRequestTracker;
1516
namespace node {
1617
class TxDownloadManagerImpl;
1718

19+
struct TxDownloadOptions {
20+
/** Read-only reference to mempool. */
21+
const CTxMemPool& m_mempool;
22+
};
23+
1824
/**
1925
* Class responsible for deciding what transactions to request and, once
2026
* downloaded, whether and how to validate them. It is also responsible for
@@ -38,7 +44,7 @@ class TxDownloadManager {
3844
const std::unique_ptr<TxDownloadManagerImpl> m_impl;
3945

4046
public:
41-
explicit TxDownloadManager();
47+
explicit TxDownloadManager(const TxDownloadOptions& options);
4248
~TxDownloadManager();
4349

4450
// Get references to internal data structures. Outside access to these data structures should be

src/node/txdownloadman_impl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
#include <chain.h>
99
#include <consensus/validation.h>
10+
#include <txmempool.h>
1011
#include <validation.h>
1112
#include <validationinterface.h>
1213

1314
namespace node {
1415
// TxDownloadManager wrappers
15-
TxDownloadManager::TxDownloadManager() :
16-
m_impl{std::make_unique<TxDownloadManagerImpl>()}
16+
TxDownloadManager::TxDownloadManager(const TxDownloadOptions& options) :
17+
m_impl{std::make_unique<TxDownloadManagerImpl>(options)}
1718
{}
1819
TxDownloadManager::~TxDownloadManager() = default;
1920

src/node/txdownloadman_impl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
#include <txorphanage.h>
1313
#include <txrequest.h>
1414

15+
class CTxMemPool;
1516
namespace node {
1617
class TxDownloadManagerImpl {
1718
public:
19+
TxDownloadOptions m_opts;
20+
1821
/** Manages unvalidated tx data (orphan transactions for which we are downloading ancestors). */
1922
TxOrphanage m_orphanage;
2023
/** Tracks candidates for requesting and downloading transaction data. */
@@ -122,7 +125,7 @@ class TxDownloadManagerImpl {
122125
return *m_lazy_recent_confirmed_transactions;
123126
}
124127

125-
TxDownloadManagerImpl() = default;
128+
TxDownloadManagerImpl(const TxDownloadOptions& options) : m_opts{options} {}
126129

127130
void ActiveTipChange();
128131
void BlockConnected(const std::shared_ptr<const CBlock>& pblock);

0 commit comments

Comments
 (0)