From 7878f97bf15b6e7c9b47d1c0d96419b97e1bdcbd Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Mon, 17 Jan 2022 20:35:02 -0500 Subject: 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. --- src/node/interfaces.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/node') diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 414eff7125..56b5a928ad 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -402,6 +402,7 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLockGetBlockTimeMax(); if (block.m_mtp_time) *block.m_mtp_time = index->GetMedianTimePast(); if (block.m_in_active_chain) *block.m_in_active_chain = active[index->nHeight] == index; + if (block.m_locator) { *block.m_locator = active.GetLocator(index); } if (block.m_next_block) FillBlock(active[index->nHeight] == index ? active[index->nHeight + 1] : nullptr, *block.m_next_block, lock, active); if (block.m_data) { REVERSE_LOCK(lock); -- cgit v1.2.3