aboutsummaryrefslogtreecommitdiff
path: root/src/node/blockstorage.cpp
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2022-03-15 19:19:58 -0400
committerCarl Dong <contact@carldong.me>2022-03-15 19:42:43 -0400
commit28ba0313eac37e4a900b7e97af7169ce999c4024 (patch)
tree0e082ed3f96cbbefa53c23c1812d272d5a4862e9 /src/node/blockstorage.cpp
parent12eb05df63f930969115af6dc66e2e5d02f2a517 (diff)
downloadbitcoin-28ba0313eac37e4a900b7e97af7169ce999c4024.tar.xz
Add and use CBlockIndexHeightOnlyComparator
...also use std::sort for clarity
Diffstat (limited to 'src/node/blockstorage.cpp')
-rw-r--r--src/node/blockstorage.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index bbdd240692..73bc4e0072 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -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;