Add and use BlockManager::GetAllBlockIndices

This commit is contained in:
Carl Dong
2022-03-15 19:28:46 -04:00
parent 28ba0313ea
commit f865cf8ded
3 changed files with 15 additions and 10 deletions

View File

@@ -4069,11 +4069,7 @@ bool ChainstateManager::LoadBlockIndex()
bool ret = m_blockman.LoadBlockIndexDB();
if (!ret) return false;
std::vector<CBlockIndex*> vSortedByHeight;
vSortedByHeight.reserve(m_blockman.m_block_index.size());
for (auto& [_, block_index] : m_blockman.m_block_index) {
vSortedByHeight.push_back(&block_index);
}
std::vector<CBlockIndex*> vSortedByHeight{m_blockman.GetAllBlockIndices()};
std::sort(vSortedByHeight.begin(), vSortedByHeight.end(),
CBlockIndexHeightOnlyComparator());