Skip to content

Commit fa9bd7b

Browse files
author
MarcoFalke
committed
Move ::fImporting to BlockManager
1 parent fa442b1 commit fa9bd7b

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/node/blockstorage.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <unordered_map>
2727

2828
namespace node {
29-
std::atomic_bool fImporting(false);
3029
std::atomic_bool fReindex(false);
3130

3231
bool CBlockIndexWorkComparator::operator()(const CBlockIndex* pa, const CBlockIndex* pb) const
@@ -867,7 +866,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
867866
ScheduleBatchPriority();
868867

869868
{
870-
ImportingNow imp{fImporting};
869+
ImportingNow imp{chainman.m_blockman.m_importing};
871870

872871
// -reindex
873872
if (fReindex) {

src/node/blockstorage.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
4747
/** Size of header written by WriteBlockToDisk before a serialized CBlock */
4848
static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE = CMessageHeader::MESSAGE_START_SIZE + sizeof(unsigned int);
4949

50-
extern std::atomic_bool fImporting;
5150
extern std::atomic_bool fReindex;
5251

5352
// Because validation code takes pointers to the map's CBlockIndex objects, if
@@ -148,6 +147,8 @@ class BlockManager
148147
: m_prune_mode{opts.prune_target > 0},
149148
m_opts{std::move(opts)} {};
150149

150+
std::atomic<bool> m_importing{false};
151+
151152
BlockMap m_block_index GUARDED_BY(cs_main);
152153

153154
std::vector<CBlockIndex*> GetAllBlockIndices() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
@@ -195,10 +196,7 @@ class BlockManager
195196
/** Attempt to stay below this number of bytes of block files. */
196197
[[nodiscard]] uint64_t GetPruneTarget() const { return m_opts.prune_target; }
197198

198-
[[nodiscard]] bool LoadingBlocks() const
199-
{
200-
return fImporting || fReindex;
201-
}
199+
[[nodiscard]] bool LoadingBlocks() const { return m_importing || fReindex; }
202200

203201
/** Calculate the amount of disk space the block & undo files currently use */
204202
uint64_t CalculateCurrentUsage();

src/node/interfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class NodeImpl : public Node
295295
bool isInitialBlockDownload() override {
296296
return chainman().ActiveChainstate().IsInitialBlockDownload();
297297
}
298-
bool isLoadingBlocks() override { return node::fReindex || node::fImporting; }
298+
bool isLoadingBlocks() override { return chainman().m_blockman.LoadingBlocks(); }
299299
void setNetworkActive(bool active) override
300300
{
301301
if (m_context->connman) {

0 commit comments

Comments
 (0)