| 4918 | } |
| 4919 | |
| 4920 | bool ChainstateManager::LoadBlockIndex() |
| 4921 | { |
| 4922 | AssertLockHeld(cs_main); |
| 4923 | // Load block index from databases |
| 4924 | if (m_blockman.m_blockfiles_indexed) { |
| 4925 | bool ret{m_blockman.LoadBlockIndexDB(CurrentChainstate().m_from_snapshot_blockhash)}; |
| 4926 | if (!ret) return false; |
| 4927 | |
| 4928 | m_blockman.ScanAndUnlinkAlreadyPrunedFiles(); |
| 4929 | |
| 4930 | std::vector<CBlockIndex*> vSortedByHeight{m_blockman.GetAllBlockIndices()}; |
| 4931 | std::sort(vSortedByHeight.begin(), vSortedByHeight.end(), |
| 4932 | CBlockIndexHeightOnlyComparator()); |
| 4933 | |
| 4934 | for (CBlockIndex* pindex : vSortedByHeight) { |
| 4935 | if (m_interrupt) return false; |
| 4936 | if (pindex->nStatus & BLOCK_FAILED_VALID && (!m_best_invalid || pindex->nChainWork > m_best_invalid->nChainWork)) { |
| 4937 | m_best_invalid = pindex; |
| 4938 | } |
| 4939 | if (pindex->IsValid(BLOCK_VALID_TREE) && (m_best_header == nullptr || CBlockIndexWorkComparator()(m_best_header, pindex))) |
| 4940 | m_best_header = pindex; |
| 4941 | } |
| 4942 | } |
| 4943 | return true; |
| 4944 | } |
| 4945 | |
| 4946 | bool Chainstate::LoadGenesisBlock() |
| 4947 | { |
nothing calls this directly
no test coverage detected