mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-11 09:42:17 +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:
@@ -2641,7 +2641,7 @@ bool Chainstate::FlushStateToDisk(
|
||||
|
||||
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState();
|
||||
LOCK(m_blockman.cs_LastBlockFile);
|
||||
if (m_blockman.IsPruneMode() && (m_blockman.m_check_for_pruning || nManualPruneHeight > 0) && !m_chainman.m_blockman.m_reindexing) {
|
||||
if (m_blockman.IsPruneMode() && (m_blockman.m_check_for_pruning || nManualPruneHeight > 0) && m_chainman.m_blockman.m_blockfiles_indexed) {
|
||||
// make sure we don't prune above any of the prune locks bestblocks
|
||||
// pruning is height-based
|
||||
int last_prune{m_chain.Height()}; // last height we can prune
|
||||
@@ -3254,10 +3254,10 @@ bool Chainstate::ActivateBestChainStep(BlockValidationState& state, CBlockIndex*
|
||||
return true;
|
||||
}
|
||||
|
||||
static SynchronizationState GetSynchronizationState(bool init, bool reindexing)
|
||||
static SynchronizationState GetSynchronizationState(bool init, bool blockfiles_indexed)
|
||||
{
|
||||
if (!init) return SynchronizationState::POST_INIT;
|
||||
if (reindexing) return SynchronizationState::INIT_REINDEX;
|
||||
if (!blockfiles_indexed) return SynchronizationState::INIT_REINDEX;
|
||||
return SynchronizationState::INIT_DOWNLOAD;
|
||||
}
|
||||
|
||||
@@ -3279,7 +3279,7 @@ static bool NotifyHeaderTip(ChainstateManager& chainman) LOCKS_EXCLUDED(cs_main)
|
||||
}
|
||||
// Send block tip changed notifications without cs_main
|
||||
if (fNotify) {
|
||||
chainman.GetNotifications().headerTip(GetSynchronizationState(fInitialBlockDownload, chainman.m_blockman.m_reindexing), pindexHeader->nHeight, pindexHeader->nTime, false);
|
||||
chainman.GetNotifications().headerTip(GetSynchronizationState(fInitialBlockDownload, chainman.m_blockman.m_blockfiles_indexed), pindexHeader->nHeight, pindexHeader->nTime, false);
|
||||
}
|
||||
return fNotify;
|
||||
}
|
||||
@@ -3398,7 +3398,7 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
|
||||
}
|
||||
|
||||
// Always notify the UI if a new block tip was connected
|
||||
if (kernel::IsInterrupted(m_chainman.GetNotifications().blockTip(GetSynchronizationState(still_in_ibd, m_chainman.m_blockman.m_reindexing), *pindexNewTip))) {
|
||||
if (kernel::IsInterrupted(m_chainman.GetNotifications().blockTip(GetSynchronizationState(still_in_ibd, m_chainman.m_blockman.m_blockfiles_indexed), *pindexNewTip))) {
|
||||
// Just breaking and returning success for now. This could
|
||||
// be changed to bubble up the kernel::Interrupted value to
|
||||
// the caller so the caller could distinguish between
|
||||
@@ -3624,7 +3624,7 @@ bool Chainstate::InvalidateBlock(BlockValidationState& state, CBlockIndex* pinde
|
||||
// parameter indicating the source of the tip change so hooks can
|
||||
// distinguish user-initiated invalidateblock changes from other
|
||||
// changes.
|
||||
(void)m_chainman.GetNotifications().blockTip(GetSynchronizationState(m_chainman.IsInitialBlockDownload(), m_chainman.m_blockman.m_reindexing), *to_mark_failed->pprev);
|
||||
(void)m_chainman.GetNotifications().blockTip(GetSynchronizationState(m_chainman.IsInitialBlockDownload(), m_chainman.m_blockman.m_blockfiles_indexed), *to_mark_failed->pprev);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -4263,7 +4263,7 @@ void ChainstateManager::ReportHeadersPresync(const arith_uint256& work, int64_t
|
||||
m_last_presync_update = now;
|
||||
}
|
||||
bool initial_download = IsInitialBlockDownload();
|
||||
GetNotifications().headerTip(GetSynchronizationState(initial_download, m_blockman.m_reindexing), height, timestamp, /*presync=*/true);
|
||||
GetNotifications().headerTip(GetSynchronizationState(initial_download, m_blockman.m_blockfiles_indexed), height, timestamp, /*presync=*/true);
|
||||
if (initial_download) {
|
||||
int64_t blocks_left{(NodeClock::now() - NodeSeconds{std::chrono::seconds{timestamp}}) / GetConsensus().PowTargetSpacing()};
|
||||
blocks_left = std::max<int64_t>(0, blocks_left);
|
||||
@@ -4790,7 +4790,7 @@ bool ChainstateManager::LoadBlockIndex()
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
// Load block index from databases
|
||||
if (!m_blockman.m_reindexing) {
|
||||
if (m_blockman.m_blockfiles_indexed) {
|
||||
bool ret{m_blockman.LoadBlockIndexDB(SnapshotBlockhash())};
|
||||
if (!ret) return false;
|
||||
|
||||
@@ -4961,7 +4961,7 @@ void ChainstateManager::LoadExternalBlockFile(
|
||||
}
|
||||
}
|
||||
|
||||
if (m_blockman.IsPruneMode() && !m_blockman.m_reindexing && pblock) {
|
||||
if (m_blockman.IsPruneMode() && m_blockman.m_blockfiles_indexed && pblock) {
|
||||
// must update the tip for pruning to work while importing with -loadblock.
|
||||
// this is a tradeoff to conserve disk space at the expense of time
|
||||
// spent updating the tip to be able to prune.
|
||||
|
||||
Reference in New Issue
Block a user