[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.
pull/30110/head
glozow 7 months ago
parent af918349de
commit 84e4ef843d

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

@ -10,11 +10,17 @@
class CBlock;
class CRollingBloomFilter;
class CTxMemPool;
class TxOrphanage;
class TxRequestTracker;
namespace node {
class TxDownloadManagerImpl;
struct TxDownloadOptions {
/** Read-only reference to mempool. */
const CTxMemPool& m_mempool;
};
/**
* Class responsible for deciding what transactions to request and, once
* 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;
public:
explicit TxDownloadManager();
explicit TxDownloadManager(const TxDownloadOptions& options);
~TxDownloadManager();
// Get references to internal data structures. Outside access to these data structures should be

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

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

Loading…
Cancel
Save