[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.
This commit is contained in:
glozow 2024-04-16 17:04:00 +01:00
parent af918349de
commit 84e4ef843d
4 changed files with 15 additions and 4 deletions

View file

@ -2000,6 +2000,7 @@ PeerManagerImpl::PeerManagerImpl(CConnman& connman, AddrMan& addrman,
m_banman(banman), m_banman(banman),
m_chainman(chainman), m_chainman(chainman),
m_mempool(pool), m_mempool(pool),
m_txdownloadman(node::TxDownloadOptions{pool}),
m_warnings{warnings}, m_warnings{warnings},
m_opts{opts} m_opts{opts}
{ {

View file

@ -10,11 +10,17 @@
class CBlock; class CBlock;
class CRollingBloomFilter; class CRollingBloomFilter;
class CTxMemPool;
class TxOrphanage; class TxOrphanage;
class TxRequestTracker; class TxRequestTracker;
namespace node { namespace node {
class TxDownloadManagerImpl; class TxDownloadManagerImpl;
struct TxDownloadOptions {
/** Read-only reference to mempool. */
const CTxMemPool& m_mempool;
};
/** /**
* Class responsible for deciding what transactions to request and, once * Class responsible for deciding what transactions to request and, once
* downloaded, whether and how to validate them. It is also responsible for * downloaded, whether and how to validate them. It is also responsible for
@ -38,7 +44,7 @@ class TxDownloadManager {
const std::unique_ptr<TxDownloadManagerImpl> m_impl; const std::unique_ptr<TxDownloadManagerImpl> m_impl;
public: public:
explicit TxDownloadManager(); explicit TxDownloadManager(const TxDownloadOptions& options);
~TxDownloadManager(); ~TxDownloadManager();
// Get references to internal data structures. Outside access to these data structures should be // Get references to internal data structures. Outside access to these data structures should be

View file

@ -7,13 +7,14 @@
#include <chain.h> #include <chain.h>
#include <consensus/validation.h> #include <consensus/validation.h>
#include <txmempool.h>
#include <validation.h> #include <validation.h>
#include <validationinterface.h> #include <validationinterface.h>
namespace node { namespace node {
// TxDownloadManager wrappers // TxDownloadManager wrappers
TxDownloadManager::TxDownloadManager() : TxDownloadManager::TxDownloadManager(const TxDownloadOptions& options) :
m_impl{std::make_unique<TxDownloadManagerImpl>()} m_impl{std::make_unique<TxDownloadManagerImpl>(options)}
{} {}
TxDownloadManager::~TxDownloadManager() = default; TxDownloadManager::~TxDownloadManager() = default;

View file

@ -12,9 +12,12 @@
#include <txorphanage.h> #include <txorphanage.h>
#include <txrequest.h> #include <txrequest.h>
class CTxMemPool;
namespace node { namespace node {
class TxDownloadManagerImpl { class TxDownloadManagerImpl {
public: public:
TxDownloadOptions m_opts;
/** Manages unvalidated tx data (orphan transactions for which we are downloading ancestors). */ /** Manages unvalidated tx data (orphan transactions for which we are downloading ancestors). */
TxOrphanage m_orphanage; TxOrphanage m_orphanage;
/** Tracks candidates for requesting and downloading transaction data. */ /** Tracks candidates for requesting and downloading transaction data. */
@ -122,7 +125,7 @@ public:
return *m_lazy_recent_confirmed_transactions; return *m_lazy_recent_confirmed_transactions;
} }
TxDownloadManagerImpl() = default; TxDownloadManagerImpl(const TxDownloadOptions& options) : m_opts{options} {}
void ActiveTipChange(); void ActiveTipChange();
void BlockConnected(const std::shared_ptr<const CBlock>& pblock); void BlockConnected(const std::shared_ptr<const CBlock>& pblock);