mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 16:24:48 +02:00
indexes, refactor: Remove CChainState use in index CommitInternal method
Replace CommitInternal method with CustomCommit and use interfaces::Chain instead of CChainState to generate block locator. This commit does not change behavior in any way, except in the (m_best_block_index == nullptr) case, which was added recently in https://github.com/bitcoin/bitcoin/pull/24117 as part of an ongoing attempt to prevent index corruption if bitcoind is interrupted during startup. New behavior in that case should be slightly better than the old behavior (skipping the entire custom+base commit now vs only skipping the base commit previously) and this might avoid more cases of corruption.
This commit is contained in:
@@ -57,6 +57,8 @@ public:
|
||||
FoundBlock& mtpTime(int64_t& mtp_time) { m_mtp_time = &mtp_time; return *this; }
|
||||
//! Return whether block is in the active (most-work) chain.
|
||||
FoundBlock& inActiveChain(bool& in_active_chain) { m_in_active_chain = &in_active_chain; return *this; }
|
||||
//! Return locator if block is in the active chain.
|
||||
FoundBlock& locator(CBlockLocator& locator) { m_locator = &locator; return *this; }
|
||||
//! Return next block in the active chain if current block is in the active chain.
|
||||
FoundBlock& nextBlock(const FoundBlock& next_block) { m_next_block = &next_block; return *this; }
|
||||
//! Read block data from disk. If the block exists but doesn't have data
|
||||
@@ -69,6 +71,7 @@ public:
|
||||
int64_t* m_max_time = nullptr;
|
||||
int64_t* m_mtp_time = nullptr;
|
||||
bool* m_in_active_chain = nullptr;
|
||||
CBlockLocator* m_locator = nullptr;
|
||||
const FoundBlock* m_next_block = nullptr;
|
||||
CBlock* m_data = nullptr;
|
||||
mutable bool found = false;
|
||||
|
||||
Reference in New Issue
Block a user