| 5216 | } |
| 5217 | |
| 5218 | bool Chainstate::LoadChainTip() { |
| 5219 | AssertLockHeld(cs_main); |
| 5220 | const CCoinsViewCache &coins_cache = CoinsTip(); |
| 5221 | // Never called when the coins view is empty |
| 5222 | assert(!coins_cache.GetBestBlock().IsNull()); |
| 5223 | const CBlockIndex *tip = m_chain.Tip(); |
| 5224 | |
| 5225 | if (tip && tip->GetBlockHash() == coins_cache.GetBestBlock()) { |
| 5226 | return true; |
| 5227 | } |
| 5228 | |
| 5229 | // Load pointer to end of best chain |
| 5230 | CBlockIndex *pindex = |
| 5231 | m_blockman.LookupBlockIndex(coins_cache.GetBestBlock()); |
| 5232 | if (!pindex) { |
| 5233 | return false; |
| 5234 | } |
| 5235 | m_chain.SetTip(*pindex); |
| 5236 | PruneBlockIndexCandidates(); |
| 5237 | |
| 5238 | tip = m_chain.Tip(); |
| 5239 | LogPrintf( |
| 5240 | "Loaded best chain: hashBestChain=%s height=%d date=%s progress=%f\n", |
| 5241 | tip->GetBlockHash().ToString(), m_chain.Height(), |
| 5242 | FormatISO8601DateTime(tip->GetBlockTime()), |
| 5243 | GuessVerificationProgress(m_chainman.GetParams().TxData(), tip)); |
| 5244 | return true; |
| 5245 | } |
| 5246 | |
| 5247 | CVerifyDB::CVerifyDB(Notifications ¬ifications) |
| 5248 | : m_notifications{notifications} { |