MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / SetBestBlockIndex

Method SetBestBlockIndex

src/index/base.cpp:493–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493void BaseIndex::SetBestBlockIndex(const CBlockIndex* block)
494{
495 assert(!m_chainstate->m_blockman.IsPruneMode() || AllowPrune());
496
497 if (AllowPrune() && block) {
498 node::PruneLockInfo prune_lock;
499 prune_lock.height_first = block->nHeight;
500 WITH_LOCK(::cs_main, m_chainstate->m_blockman.UpdatePruneLock(GetName(), prune_lock));
501 }
502
503 // Intentionally set m_best_block_index as the last step in this function,
504 // after updating prune locks above, and after making any other references
505 // to *this, so the BlockUntilSyncedToCurrentChain function (which checks
506 // m_best_block_index as an optimization) can be used to wait for the last
507 // BlockConnected notification and safely assume that prune locks are
508 // updated and that the index object is safe to delete.
509 m_best_block_index = block;
510}

Callers

nothing calls this directly

Calls 2

IsPruneModeMethod · 0.80
UpdatePruneLockMethod · 0.80

Tested by

no test coverage detected