mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
blockman: Replace m_reindexing with m_blockfiles_indexed
This is a just a mechanical change, renaming and inverting the meaning of the indexing variable. "m_blockfiles_indexed" is a more straightforward name for this variable because this variable just indicates whether or not <datadir>/blocks/blk?????.dat files have been indexed in the <datadir>/blocks/index LevelDB database. The name "m_reindexing" was more confusing, it could be true even if -reindex was not specified, and false when it was specified. Also, the previous name unnecessarily required thinking about the whole reindexing process just to understand simple checks in validation code about whether blocks were indexed. The motivation for this change is to follow up on previous commits, moving away from having multiple variables called "reindex" internally, and instead naming variables individually after what they do and represent.
This commit is contained in:
@@ -551,7 +551,7 @@ bool BlockManager::LoadBlockIndexDB(const std::optional<uint256>& snapshot_block
|
||||
// Check whether we need to continue reindexing
|
||||
bool fReindexing = false;
|
||||
m_block_tree_db->ReadReindexing(fReindexing);
|
||||
if (fReindexing) m_reindexing = true;
|
||||
if (fReindexing) m_blockfiles_indexed = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1182,7 +1182,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
||||
ImportingNow imp{chainman.m_blockman.m_importing};
|
||||
|
||||
// -reindex
|
||||
if (chainman.m_blockman.m_reindexing) {
|
||||
if (!chainman.m_blockman.m_blockfiles_indexed) {
|
||||
int nFile = 0;
|
||||
// Map of disk positions for blocks with unknown parent (only used for reindex);
|
||||
// parent hash -> child disk position, multiple children can have the same parent.
|
||||
@@ -1205,7 +1205,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
||||
nFile++;
|
||||
}
|
||||
WITH_LOCK(::cs_main, chainman.m_blockman.m_block_tree_db->WriteReindexing(false));
|
||||
chainman.m_blockman.m_reindexing = false;
|
||||
chainman.m_blockman.m_blockfiles_indexed = true;
|
||||
LogPrintf("Reindexing finished\n");
|
||||
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
|
||||
chainman.ActiveChainstate().LoadGenesisBlock();
|
||||
|
||||
Reference in New Issue
Block a user