Skip to content

Commit b8067cd

Browse files
author
MacroFake
committed
Merge bitcoin#22485: doc: BaseIndex sync behavior with empty datadir
11780f2 doc: BaseIndex sync behavior with empty datadir (James O'Beirne) Pull request description: Make a note about a potentially confusing behavior with `BaseIndex::m_synced`; if the user starts bitcoind with an empty datadir and an index enabled, BaseIndex will consider itself synced (as a degenerate case). This affects how indices are built during IBD (relying solely on BlockConnected signals vs. using ThreadSync()). ACKs for top commit: mzumsande: ACK 11780f2 Tree-SHA512: 0b530379e57c62e05d2ddca7bb8e2c936786fa00678f9eaa1bb3742d957c48f141d46f936734b03f6673d964abc7eb72c1769f1784b9d3563d218e96296b7afd
2 parents d1e4265 + 11780f2 commit b8067cd

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/index/base.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ bool BaseIndex::Init()
8585
} else {
8686
SetBestBlockIndex(m_chainstate->FindForkInGlobalIndex(locator));
8787
}
88+
89+
// Note: this will latch to true immediately if the user starts up with an empty
90+
// datadir and an index enabled. If this is the case, indexation will happen solely
91+
// via `BlockConnected` signals until, possibly, the next restart.
8892
m_synced = m_best_block_index.load() == active_chain.Tip();
8993
if (!m_synced) {
9094
bool prune_violation = false;

src/index/base.h

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class BaseIndex : public CValidationInterface
5555
/// Whether the index is in sync with the main chain. The flag is flipped
5656
/// from false to true once, after which point this starts processing
5757
/// ValidationInterface notifications to stay in sync.
58+
///
59+
/// Note that this will latch to true *immediately* upon startup if
60+
/// `m_chainstate->m_chain` is empty, which will be the case upon startup
61+
/// with an empty datadir if, e.g., `-txindex=1` is specified.
5862
std::atomic<bool> m_synced{false};
5963

6064
/// The last block in the chain that the index is in sync with.

0 commit comments

Comments
 (0)