From fa442b137764e0b6c0d991ba641e90c3217be1bf Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 3 Jan 2023 13:06:03 +0100 Subject: [PATCH] Pass fImporting to ImportingNow helper class --- src/node/blockstorage.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 4d2d5daf052..46c306fc371 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -844,17 +844,20 @@ FlatFilePos BlockManager::SaveBlockToDisk(const CBlock& block, int nHeight, CCha return blockPos; } -struct CImportingNow { - CImportingNow() - { - assert(fImporting == false); - fImporting = true; - } +class ImportingNow +{ + std::atomic& m_importing; - ~CImportingNow() +public: + ImportingNow(std::atomic& importing) : m_importing{importing} { - assert(fImporting == true); - fImporting = false; + assert(m_importing == false); + m_importing = true; + } + ~ImportingNow() + { + assert(m_importing == true); + m_importing = false; } }; @@ -864,7 +867,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector vImportFile ScheduleBatchPriority(); { - CImportingNow imp; + ImportingNow imp{fImporting}; // -reindex if (fReindex) { @@ -930,7 +933,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector vImportFile StartShutdown(); return; } - } // End scope of CImportingNow + } // End scope of ImportingNow chainman.ActiveChainstate().LoadMempool(mempool_path); } } // namespace node