mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Add and use CBlockIndexHeightOnlyComparator
...also use std::sort for clarity
This commit is contained in:
@@ -47,6 +47,11 @@ bool CBlockIndexWorkComparator::operator()(const CBlockIndex* pa, const CBlockIn
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBlockIndexHeightOnlyComparator::operator()(const CBlockIndex* pa, const CBlockIndex* pb) const
|
||||
{
|
||||
return pa->nHeight < pb->nHeight;
|
||||
}
|
||||
|
||||
static FILE* OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false);
|
||||
static FlatFileSeq BlockFileSeq();
|
||||
static FlatFileSeq UndoFileSeq();
|
||||
@@ -242,10 +247,8 @@ bool BlockManager::LoadBlockIndex(const Consensus::Params& consensus_params)
|
||||
for (auto& [_, block_index] : 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());
|
||||
|
||||
for (CBlockIndex* pindex : vSortedByHeight) {
|
||||
if (ShutdownRequested()) return false;
|
||||
|
||||
Reference in New Issue
Block a user