diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 46c306fc371..4356fc2b2a6 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -26,7 +26,6 @@ #include namespace node { -std::atomic_bool fImporting(false); std::atomic_bool fReindex(false); bool CBlockIndexWorkComparator::operator()(const CBlockIndex* pa, const CBlockIndex* pb) const @@ -867,7 +866,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector vImportFile ScheduleBatchPriority(); { - ImportingNow imp{fImporting}; + ImportingNow imp{chainman.m_blockman.m_importing}; // -reindex if (fReindex) { diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index 78ca727c995..de9b1c0bb57 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -47,7 +47,6 @@ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB /** Size of header written by WriteBlockToDisk before a serialized CBlock */ static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE = CMessageHeader::MESSAGE_START_SIZE + sizeof(unsigned int); -extern std::atomic_bool fImporting; extern std::atomic_bool fReindex; // Because validation code takes pointers to the map's CBlockIndex objects, if @@ -148,6 +147,8 @@ public: : m_prune_mode{opts.prune_target > 0}, m_opts{std::move(opts)} {}; + std::atomic m_importing{false}; + BlockMap m_block_index GUARDED_BY(cs_main); std::vector GetAllBlockIndices() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); @@ -195,10 +196,7 @@ public: /** Attempt to stay below this number of bytes of block files. */ [[nodiscard]] uint64_t GetPruneTarget() const { return m_opts.prune_target; } - [[nodiscard]] bool LoadingBlocks() const - { - return fImporting || fReindex; - } + [[nodiscard]] bool LoadingBlocks() const { return m_importing || fReindex; } /** Calculate the amount of disk space the block & undo files currently use */ uint64_t CalculateCurrentUsage(); diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 54aa21e9844..b397661df40 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -295,7 +295,7 @@ public: bool isInitialBlockDownload() override { return chainman().ActiveChainstate().IsInitialBlockDownload(); } - bool isLoadingBlocks() override { return node::fReindex || node::fImporting; } + bool isLoadingBlocks() override { return chainman().m_blockman.LoadingBlocks(); } void setNetworkActive(bool active) override { if (m_context->connman) {