@@ -203,8 +203,7 @@ CBlockIndex* BlockManager::InsertBlockIndex(const uint256& hash)
203
203
return nullptr ;
204
204
}
205
205
206
- // Return existing or create new
207
- auto [mi, inserted] = m_block_index.try_emplace (hash);
206
+ const auto [mi, inserted]{m_block_index.try_emplace (hash)};
208
207
CBlockIndex* pindex = &(*mi).second ;
209
208
if (inserted) {
210
209
pindex->phashBlock = &((*mi).first );
@@ -224,8 +223,7 @@ bool BlockManager::LoadBlockIndex(
224
223
std::vector<std::pair<int , CBlockIndex*>> vSortedByHeight;
225
224
vSortedByHeight.reserve (m_block_index.size ());
226
225
for (auto & [_, block_index] : m_block_index) {
227
- CBlockIndex* pindex = &block_index;
228
- vSortedByHeight.push_back (std::make_pair (pindex->nHeight , pindex));
226
+ vSortedByHeight.push_back (std::make_pair (block_index.nHeight , &block_index));
229
227
}
230
228
sort (vSortedByHeight.begin (), vSortedByHeight.end ());
231
229
@@ -382,9 +380,8 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
382
380
LogPrintf (" Checking all blk files are present...\n " );
383
381
std::set<int > setBlkDataFiles;
384
382
for (const auto & [_, block_index] : m_block_index) {
385
- const CBlockIndex* pindex = &block_index;
386
- if (pindex->nStatus & BLOCK_HAVE_DATA) {
387
- setBlkDataFiles.insert (pindex->nFile );
383
+ if (block_index.nStatus & BLOCK_HAVE_DATA) {
384
+ setBlkDataFiles.insert (block_index.nFile );
388
385
}
389
386
}
390
387
for (std::set<int >::iterator it = setBlkDataFiles.begin (); it != setBlkDataFiles.end (); it++) {
0 commit comments