Move ::fImporting to BlockManager

This commit is contained in:
MarcoFalke 2023-01-03 13:09:55 +01:00
parent fa442b1377
commit fa9bd7be47
No known key found for this signature in database
3 changed files with 5 additions and 8 deletions

View File

@ -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) {

View File

@ -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();

View File

@ -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) {