mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 14:14:00 +01:00
[refactor] add CheckIsEmpty and GetOrphanTransactions, remove access to TxDownloadMan internals
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <net.h>
|
||||
#include <policy/packages.h>
|
||||
#include <txorphanage.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
@@ -15,7 +16,6 @@ class CBlock;
|
||||
class CRollingBloomFilter;
|
||||
class CTxMemPool;
|
||||
class GenTxid;
|
||||
class TxOrphanage;
|
||||
class TxRequestTracker;
|
||||
namespace node {
|
||||
class TxDownloadManagerImpl;
|
||||
@@ -121,11 +121,6 @@ public:
|
||||
explicit TxDownloadManager(const TxDownloadOptions& options);
|
||||
~TxDownloadManager();
|
||||
|
||||
// Get references to internal data structures. Outside access to these data structures should be
|
||||
// temporary and removed later once logic has been moved internally.
|
||||
TxOrphanage& GetOrphanageRef();
|
||||
TxRequestTracker& GetTxRequestRef();
|
||||
|
||||
// Responses to chain events. TxDownloadManager is not an actual client of ValidationInterface, these are called through PeerManager.
|
||||
void ActiveTipChange();
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock);
|
||||
@@ -167,6 +162,15 @@ public:
|
||||
|
||||
/** Returns next orphan tx to consider, or nullptr if none exist. */
|
||||
CTransactionRef GetTxToReconsider(NodeId nodeid);
|
||||
|
||||
/** Check that all data structures are empty. */
|
||||
void CheckIsEmpty() const;
|
||||
|
||||
/** Check that all data structures that track per-peer information have nothing for this peer. */
|
||||
void CheckIsEmpty(NodeId nodeid) const;
|
||||
|
||||
/** Wrapper for TxOrphanage::GetOrphanTransactions */
|
||||
std::vector<TxOrphanage::OrphanTxBase> GetOrphanTransactions() const;
|
||||
};
|
||||
} // namespace node
|
||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
||||
|
||||
@@ -19,14 +19,6 @@ TxDownloadManager::TxDownloadManager(const TxDownloadOptions& options) :
|
||||
{}
|
||||
TxDownloadManager::~TxDownloadManager() = default;
|
||||
|
||||
TxOrphanage& TxDownloadManager::GetOrphanageRef()
|
||||
{
|
||||
return m_impl->m_orphanage;
|
||||
}
|
||||
TxRequestTracker& TxDownloadManager::GetTxRequestRef()
|
||||
{
|
||||
return m_impl->m_txrequest;
|
||||
}
|
||||
void TxDownloadManager::ActiveTipChange()
|
||||
{
|
||||
m_impl->ActiveTipChange();
|
||||
@@ -83,6 +75,18 @@ CTransactionRef TxDownloadManager::GetTxToReconsider(NodeId nodeid)
|
||||
{
|
||||
return m_impl->GetTxToReconsider(nodeid);
|
||||
}
|
||||
void TxDownloadManager::CheckIsEmpty() const
|
||||
{
|
||||
m_impl->CheckIsEmpty();
|
||||
}
|
||||
void TxDownloadManager::CheckIsEmpty(NodeId nodeid) const
|
||||
{
|
||||
m_impl->CheckIsEmpty(nodeid);
|
||||
}
|
||||
std::vector<TxOrphanage::OrphanTxBase> TxDownloadManager::GetOrphanTransactions() const
|
||||
{
|
||||
return m_impl->GetOrphanTransactions();
|
||||
}
|
||||
|
||||
// TxDownloadManagerImpl
|
||||
void TxDownloadManagerImpl::ActiveTipChange()
|
||||
@@ -515,4 +519,18 @@ CTransactionRef TxDownloadManagerImpl::GetTxToReconsider(NodeId nodeid)
|
||||
return m_orphanage.GetTxToReconsider(nodeid);
|
||||
}
|
||||
|
||||
void TxDownloadManagerImpl::CheckIsEmpty(NodeId nodeid)
|
||||
{
|
||||
assert(m_txrequest.Count(nodeid) == 0);
|
||||
}
|
||||
void TxDownloadManagerImpl::CheckIsEmpty()
|
||||
{
|
||||
assert(m_orphanage.Size() == 0);
|
||||
assert(m_txrequest.Size() == 0);
|
||||
assert(m_num_wtxid_peers == 0);
|
||||
}
|
||||
std::vector<TxOrphanage::OrphanTxBase> TxDownloadManagerImpl::GetOrphanTransactions() const
|
||||
{
|
||||
return m_orphanage.GetOrphanTransactions();
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -182,6 +182,11 @@ public:
|
||||
|
||||
bool HaveMoreWork(NodeId nodeid);
|
||||
CTransactionRef GetTxToReconsider(NodeId nodeid);
|
||||
|
||||
void CheckIsEmpty();
|
||||
void CheckIsEmpty(NodeId nodeid);
|
||||
|
||||
std::vector<TxOrphanage::OrphanTxBase> GetOrphanTransactions() const;
|
||||
};
|
||||
} // namespace node
|
||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
||||
|
||||
Reference in New Issue
Block a user