mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-14 06:32:33 +01:00
[refactor] move ValidationInterface functions to TxDownloadManager
This is move-only.
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
class CBlock;
|
||||
class CRollingBloomFilter;
|
||||
class TxOrphanage;
|
||||
class TxRequestTracker;
|
||||
class CRollingBloomFilter;
|
||||
|
||||
namespace node {
|
||||
class TxDownloadManagerImpl;
|
||||
|
||||
@@ -48,6 +48,11 @@ public:
|
||||
CRollingBloomFilter& RecentRejectsFilter();
|
||||
CRollingBloomFilter& RecentRejectsReconsiderableFilter();
|
||||
CRollingBloomFilter& RecentConfirmedTransactionsFilter();
|
||||
|
||||
// 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);
|
||||
void BlockDisconnected();
|
||||
};
|
||||
} // namespace node
|
||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
||||
|
||||
@@ -5,7 +5,13 @@
|
||||
#include <node/txdownloadman_impl.h>
|
||||
#include <node/txdownloadman.h>
|
||||
|
||||
#include <chain.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
|
||||
namespace node {
|
||||
// TxDownloadManager wrappers
|
||||
TxDownloadManager::TxDownloadManager() :
|
||||
m_impl{std::make_unique<TxDownloadManagerImpl>()}
|
||||
{}
|
||||
@@ -31,4 +37,50 @@ CRollingBloomFilter& TxDownloadManager::RecentConfirmedTransactionsFilter()
|
||||
{
|
||||
return m_impl->RecentConfirmedTransactionsFilter();
|
||||
}
|
||||
void TxDownloadManager::ActiveTipChange()
|
||||
{
|
||||
m_impl->ActiveTipChange();
|
||||
}
|
||||
void TxDownloadManager::BlockConnected(const std::shared_ptr<const CBlock>& pblock)
|
||||
{
|
||||
m_impl->BlockConnected(pblock);
|
||||
}
|
||||
void TxDownloadManager::BlockDisconnected()
|
||||
{
|
||||
m_impl->BlockDisconnected();
|
||||
}
|
||||
|
||||
// TxDownloadManagerImpl
|
||||
void TxDownloadManagerImpl::ActiveTipChange()
|
||||
{
|
||||
RecentRejectsFilter().reset();
|
||||
RecentRejectsReconsiderableFilter().reset();
|
||||
}
|
||||
|
||||
void TxDownloadManagerImpl::BlockConnected(const std::shared_ptr<const CBlock>& pblock)
|
||||
{
|
||||
m_orphanage.EraseForBlock(*pblock);
|
||||
|
||||
for (const auto& ptx : pblock->vtx) {
|
||||
RecentConfirmedTransactionsFilter().insert(ptx->GetHash().ToUint256());
|
||||
if (ptx->HasWitness()) {
|
||||
RecentConfirmedTransactionsFilter().insert(ptx->GetWitnessHash().ToUint256());
|
||||
}
|
||||
m_txrequest.ForgetTxHash(ptx->GetHash());
|
||||
m_txrequest.ForgetTxHash(ptx->GetWitnessHash());
|
||||
}
|
||||
}
|
||||
|
||||
void TxDownloadManagerImpl::BlockDisconnected()
|
||||
{
|
||||
// To avoid relay problems with transactions that were previously
|
||||
// confirmed, clear our filter of recently confirmed transactions whenever
|
||||
// there's a reorg.
|
||||
// This means that in a 1-block reorg (where 1 block is disconnected and
|
||||
// then another block reconnected), our filter will drop to having only one
|
||||
// block's worth of transactions in it, but that should be fine, since
|
||||
// presumably the most common case of relaying a confirmed transaction
|
||||
// should be just after a new block containing it is found.
|
||||
RecentConfirmedTransactionsFilter().reset();
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <node/txdownloadman.h>
|
||||
|
||||
#include <common/bloom.h>
|
||||
#include <kernel/chain.h>
|
||||
#include <net.h>
|
||||
#include <txorphanage.h>
|
||||
#include <txrequest.h>
|
||||
@@ -122,6 +123,10 @@ public:
|
||||
}
|
||||
|
||||
TxDownloadManagerImpl() = default;
|
||||
|
||||
void ActiveTipChange();
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock);
|
||||
void BlockDisconnected();
|
||||
};
|
||||
} // namespace node
|
||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
||||
|
||||
Reference in New Issue
Block a user