[refactor] Make MainSignals RAII styled

This commit is contained in:
TheCharlatan
2023-11-27 11:46:36 +01:00
parent 84f5c135b8
commit 4abde2c4e3
5 changed files with 18 additions and 45 deletions

View File

@@ -171,8 +171,7 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, const std::vecto
// from blocking due to queue overrun.
m_node.scheduler = std::make_unique<CScheduler>();
m_node.scheduler->m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { m_node.scheduler->serviceQueue(); });
m_node.validation_signals = std::make_unique<CMainSignals>();
m_node.validation_signals->RegisterBackgroundSignalScheduler(*m_node.scheduler);
m_node.validation_signals = std::make_unique<CMainSignals>(*m_node.scheduler);
m_node.fee_estimator = std::make_unique<CBlockPolicyEstimator>(FeeestPath(*m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES);
m_node.mempool = std::make_unique<CTxMemPool>(MemPoolOptionsForTest(m_node));
@@ -205,7 +204,6 @@ ChainTestingSetup::~ChainTestingSetup()
{
if (m_node.scheduler) m_node.scheduler->stop();
m_node.validation_signals->FlushBackgroundCallbacks();
m_node.validation_signals->UnregisterBackgroundSignalScheduler();
m_node.connman.reset();
m_node.banman.reset();
m_node.addrman.reset();