diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-01-03 13:09:55 +0100 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-03-15 15:48:44 +0100 |
commit | fa9bd7be472f49b15f5f87711094095954322635 (patch) | |
tree | cd29f7db26e3a0a6a7bb2039f8313806d02be52b /src/node | |
parent | fa442b137764e0b6c0d991ba641e90c3217be1bf (diff) |
Move ::fImporting to BlockManager
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/blockstorage.cpp | 3 | ||||
-rw-r--r-- | src/node/blockstorage.h | 8 | ||||
-rw-r--r-- | src/node/interfaces.cpp | 2 |
3 files changed, 5 insertions, 8 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 46c306fc37..4356fc2b2a 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -26,7 +26,6 @@ #include <unordered_map> 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<fs::path> 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 78ca727c99..de9b1c0bb5 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<bool> m_importing{false}; + BlockMap m_block_index GUARDED_BY(cs_main); std::vector<CBlockIndex*> 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 54aa21e984..b397661df4 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) { |