Skip to content

Commit fa7efc9

Browse files
author
MarcoFalke
committed
Fixup style of moved code
Can be reviewed with --word-diff-regex=. -U0 --ignore-all-space
1 parent fade2a4 commit fa7efc9

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

src/node/blockstorage.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ CBlockIndex* BlockManager::AddToBlockIndex(const CBlockHeader& block)
6262
// Check for duplicate
6363
uint256 hash = block.GetHash();
6464
BlockMap::iterator it = m_block_index.find(hash);
65-
if (it != m_block_index.end())
65+
if (it != m_block_index.end()) {
6666
return it->second;
67+
}
6768

6869
// Construct new block index object
6970
CBlockIndex* pindexNew = new CBlockIndex(block);
@@ -74,8 +75,7 @@ CBlockIndex* BlockManager::AddToBlockIndex(const CBlockHeader& block)
7475
BlockMap::iterator mi = m_block_index.insert(std::make_pair(hash, pindexNew)).first;
7576
pindexNew->phashBlock = &((*mi).first);
7677
BlockMap::iterator miPrev = m_block_index.find(block.hashPrevBlock);
77-
if (miPrev != m_block_index.end())
78-
{
78+
if (miPrev != m_block_index.end()) {
7979
pindexNew->pprev = (*miPrev).second;
8080
pindexNew->nHeight = pindexNew->pprev->nHeight + 1;
8181
pindexNew->BuildSkip();
@@ -112,7 +112,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
112112
// m_blocks_unlinked or setBlockIndexCandidates.
113113
auto range = m_blocks_unlinked.equal_range(pindex->pprev);
114114
while (range.first != range.second) {
115-
std::multimap<CBlockIndex *, CBlockIndex *>::iterator _it = range.first;
115+
std::multimap<CBlockIndex*, CBlockIndex*>::iterator _it = range.first;
116116
range.first++;
117117
if (_it->second == pindex) {
118118
m_blocks_unlinked.erase(_it);
@@ -207,17 +207,19 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
207207
nLastBlockWeCanPrune, count);
208208
}
209209

210-
CBlockIndex * BlockManager::InsertBlockIndex(const uint256& hash)
210+
CBlockIndex* BlockManager::InsertBlockIndex(const uint256& hash)
211211
{
212212
AssertLockHeld(cs_main);
213213

214-
if (hash.IsNull())
214+
if (hash.IsNull()) {
215215
return nullptr;
216+
}
216217

217218
// Return existing
218219
BlockMap::iterator mi = m_block_index.find(hash);
219-
if (mi != m_block_index.end())
220+
if (mi != m_block_index.end()) {
220221
return (*mi).second;
222+
}
221223

222224
// Create new
223225
CBlockIndex* pindexNew = new CBlockIndex();
@@ -236,10 +238,9 @@ bool BlockManager::LoadBlockIndex(
236238
}
237239

238240
// Calculate nChainWork
239-
std::vector<std::pair<int, CBlockIndex*> > vSortedByHeight;
241+
std::vector<std::pair<int, CBlockIndex*>> vSortedByHeight;
240242
vSortedByHeight.reserve(m_block_index.size());
241-
for (const std::pair<const uint256, CBlockIndex*>& item : m_block_index)
242-
{
243+
for (const std::pair<const uint256, CBlockIndex*>& item : m_block_index) {
243244
CBlockIndex* pindex = item.second;
244245
vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex));
245246
}
@@ -265,8 +266,7 @@ bool BlockManager::LoadBlockIndex(
265266
}
266267
}
267268

268-
for (const std::pair<int, CBlockIndex*>& item : vSortedByHeight)
269-
{
269+
for (const std::pair<int, CBlockIndex*>& item : vSortedByHeight) {
270270
if (ShutdownRequested()) return false;
271271
CBlockIndex* pindex = item.second;
272272
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
@@ -329,16 +329,18 @@ bool BlockManager::LoadBlockIndex(
329329
if (pindex->nStatus & BLOCK_FAILED_MASK && (!chainman.m_best_invalid || pindex->nChainWork > chainman.m_best_invalid->nChainWork)) {
330330
chainman.m_best_invalid = pindex;
331331
}
332-
if (pindex->pprev)
332+
if (pindex->pprev) {
333333
pindex->BuildSkip();
334+
}
334335
if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == nullptr || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
335336
pindexBestHeader = pindex;
336337
}
337338

338339
return true;
339340
}
340341

341-
void BlockManager::Unload() {
342+
void BlockManager::Unload()
343+
{
342344
m_blocks_unlinked.clear();
343345

344346
for (const BlockMap::value_type& entry : m_block_index) {
@@ -380,8 +382,7 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
380382
setBlkDataFiles.insert(pindex->nFile);
381383
}
382384
}
383-
for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++)
384-
{
385+
for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++) {
385386
FlatFilePos pos(*it, 0);
386387
if (CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION).IsNull()) {
387388
return false;
@@ -390,13 +391,14 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
390391

391392
// Check whether we have ever pruned block & undo files
392393
m_block_tree_db->ReadFlag("prunedblockfiles", fHavePruned);
393-
if (fHavePruned)
394+
if (fHavePruned) {
394395
LogPrintf("LoadBlockIndexDB(): Block files have previously been pruned\n");
396+
}
395397

396398
// Check whether we need to continue reindexing
397399
bool fReindexing = false;
398400
m_block_tree_db->ReadReindexing(fReindexing);
399-
if(fReindexing) fReindex = true;
401+
if (fReindexing) fReindex = true;
400402

401403
return true;
402404
}
@@ -405,8 +407,7 @@ CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data)
405407
{
406408
const MapCheckpoints& checkpoints = data.mapCheckpoints;
407409

408-
for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints))
409-
{
410+
for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints)) {
410411
const uint256& hash = i.second;
411412
CBlockIndex* pindex = LookupBlockIndex(hash);
412413
if (pindex) {

src/node/blockstorage.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ extern uint64_t nPruneTarget;
5050

5151
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
5252

53-
struct CBlockIndexWorkComparator
54-
{
55-
bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const;
53+
struct CBlockIndexWorkComparator {
54+
bool operator()(const CBlockIndex* pa, const CBlockIndex* pb) const;
5655
};
5756

5857
/**
@@ -124,7 +123,8 @@ class BlockManager
124123
//! Returns last CBlockIndex* that is a checkpoint
125124
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
126125

127-
~BlockManager() {
126+
~BlockManager()
127+
{
128128
Unload();
129129
}
130130
};

0 commit comments

Comments
 (0)