Add and use CBlockIndexHeightOnlyComparator

...also use std::sort for clarity
This commit is contained in:
Carl Dong
2022-03-15 19:19:58 -04:00
parent 12eb05df63
commit 28ba0313ea
3 changed files with 20 additions and 13 deletions

View File

@@ -65,21 +65,22 @@
using node::BLOCKFILE_CHUNK_SIZE;
using node::BlockManager;
using node::BlockMap;
using node::CBlockIndexHeightOnlyComparator;
using node::CBlockIndexWorkComparator;
using node::CCoinsStats;
using node::CoinStatsHashType;
using node::fHavePruned;
using node::fImporting;
using node::fPruneMode;
using node::fReindex;
using node::GetUTXOStats;
using node::nPruneTarget;
using node::OpenBlockFile;
using node::ReadBlockFromDisk;
using node::SnapshotMetadata;
using node::UNDOFILE_CHUNK_SIZE;
using node::UndoReadFromDisk;
using node::UnlinkPrunedFiles;
using node::fHavePruned;
using node::fImporting;
using node::fPruneMode;
using node::fReindex;
using node::nPruneTarget;
#define MICRO 0.000001
#define MILLI 0.001
@@ -4073,10 +4074,8 @@ bool ChainstateManager::LoadBlockIndex()
for (auto& [_, block_index] : m_blockman.m_block_index) {
vSortedByHeight.push_back(&block_index);
}
sort(vSortedByHeight.begin(), vSortedByHeight.end(),
[](const CBlockIndex* pa, const CBlockIndex* pb) {
return pa->nHeight < pb->nHeight;
});
std::sort(vSortedByHeight.begin(), vSortedByHeight.end(),
CBlockIndexHeightOnlyComparator());
// Find start of assumed-valid region.
int first_assumed_valid_height = std::numeric_limits<int>::max();