Changeset View
Changeset View
Standalone View
Standalone View
src/index/txindex.cpp
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | if (WriteBlock(*block, pindex)) { | ||||
m_best_block_index = pindex; | m_best_block_index = pindex; | ||||
} else { | } else { | ||||
FatalError("%s: Failed to write block %s to txindex", __func__, | FatalError("%s: Failed to write block %s to txindex", __func__, | ||||
pindex->GetBlockHash().ToString()); | pindex->GetBlockHash().ToString()); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
void TxIndex::SetBestChain(const CBlockLocator &locator) { | void TxIndex::ChainStateFlushed(const CBlockLocator &locator) { | ||||
if (!m_synced) { | if (!m_synced) { | ||||
return; | return; | ||||
} | } | ||||
const uint256 &locator_tip_hash = locator.vHave.front(); | const uint256 &locator_tip_hash = locator.vHave.front(); | ||||
const CBlockIndex *locator_tip_index; | const CBlockIndex *locator_tip_index; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
locator_tip_index = LookupBlockIndex(locator_tip_hash); | locator_tip_index = LookupBlockIndex(locator_tip_hash); | ||||
} | } | ||||
if (!locator_tip_index) { | if (!locator_tip_index) { | ||||
FatalError("%s: First block (hash=%s) in locator was not found", | FatalError("%s: First block (hash=%s) in locator was not found", | ||||
__func__, locator_tip_hash.ToString()); | __func__, locator_tip_hash.ToString()); | ||||
return; | return; | ||||
} | } | ||||
// This checks that SetBestChain callbacks are received after | // This checks that ChainStateFlushed callbacks are received after | ||||
// BlockConnected. The check may fail immediately after the the sync thread | // BlockConnected. The check may fail immediately after the the sync thread | ||||
// catches up and sets m_synced. Consider the case where there is a reorg | // catches up and sets m_synced. Consider the case where there is a reorg | ||||
// and the blocks on the stale branch are in the ValidationInterface queue | // and the blocks on the stale branch are in the ValidationInterface queue | ||||
// backlog even after the sync thread has caught up to the new chain tip. In | // backlog even after the sync thread has caught up to the new chain tip. In | ||||
// this unlikely event, log a warning and let the queue clear. | // this unlikely event, log a warning and let the queue clear. | ||||
const CBlockIndex *best_block_index = m_best_block_index.load(); | const CBlockIndex *best_block_index = m_best_block_index.load(); | ||||
if (best_block_index->GetAncestor(locator_tip_index->nHeight) != | if (best_block_index->GetAncestor(locator_tip_index->nHeight) != | ||||
locator_tip_index) { | locator_tip_index) { | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |