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