mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
Fixup style of moved code
Can be reviewed with --word-diff-regex=. -U0 --ignore-all-space
This commit is contained in:
parent
fade2a44f4
commit
fa7efc915b
2 changed files with 25 additions and 24 deletions
|
@ -62,8 +62,9 @@ CBlockIndex* BlockManager::AddToBlockIndex(const CBlockHeader& block)
|
||||||
// Check for duplicate
|
// Check for duplicate
|
||||||
uint256 hash = block.GetHash();
|
uint256 hash = block.GetHash();
|
||||||
BlockMap::iterator it = m_block_index.find(hash);
|
BlockMap::iterator it = m_block_index.find(hash);
|
||||||
if (it != m_block_index.end())
|
if (it != m_block_index.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
// Construct new block index object
|
// Construct new block index object
|
||||||
CBlockIndex* pindexNew = new CBlockIndex(block);
|
CBlockIndex* pindexNew = new CBlockIndex(block);
|
||||||
|
@ -74,8 +75,7 @@ CBlockIndex* BlockManager::AddToBlockIndex(const CBlockHeader& block)
|
||||||
BlockMap::iterator mi = m_block_index.insert(std::make_pair(hash, pindexNew)).first;
|
BlockMap::iterator mi = m_block_index.insert(std::make_pair(hash, pindexNew)).first;
|
||||||
pindexNew->phashBlock = &((*mi).first);
|
pindexNew->phashBlock = &((*mi).first);
|
||||||
BlockMap::iterator miPrev = m_block_index.find(block.hashPrevBlock);
|
BlockMap::iterator miPrev = m_block_index.find(block.hashPrevBlock);
|
||||||
if (miPrev != m_block_index.end())
|
if (miPrev != m_block_index.end()) {
|
||||||
{
|
|
||||||
pindexNew->pprev = (*miPrev).second;
|
pindexNew->pprev = (*miPrev).second;
|
||||||
pindexNew->nHeight = pindexNew->pprev->nHeight + 1;
|
pindexNew->nHeight = pindexNew->pprev->nHeight + 1;
|
||||||
pindexNew->BuildSkip();
|
pindexNew->BuildSkip();
|
||||||
|
@ -211,13 +211,15 @@ CBlockIndex * BlockManager::InsertBlockIndex(const uint256& hash)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
if (hash.IsNull())
|
if (hash.IsNull()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Return existing
|
// Return existing
|
||||||
BlockMap::iterator mi = m_block_index.find(hash);
|
BlockMap::iterator mi = m_block_index.find(hash);
|
||||||
if (mi != m_block_index.end())
|
if (mi != m_block_index.end()) {
|
||||||
return (*mi).second;
|
return (*mi).second;
|
||||||
|
}
|
||||||
|
|
||||||
// Create new
|
// Create new
|
||||||
CBlockIndex* pindexNew = new CBlockIndex();
|
CBlockIndex* pindexNew = new CBlockIndex();
|
||||||
|
@ -238,8 +240,7 @@ bool BlockManager::LoadBlockIndex(
|
||||||
// Calculate nChainWork
|
// Calculate nChainWork
|
||||||
std::vector<std::pair<int, CBlockIndex*>> vSortedByHeight;
|
std::vector<std::pair<int, CBlockIndex*>> vSortedByHeight;
|
||||||
vSortedByHeight.reserve(m_block_index.size());
|
vSortedByHeight.reserve(m_block_index.size());
|
||||||
for (const std::pair<const uint256, CBlockIndex*>& item : m_block_index)
|
for (const std::pair<const uint256, CBlockIndex*>& item : m_block_index) {
|
||||||
{
|
|
||||||
CBlockIndex* pindex = item.second;
|
CBlockIndex* pindex = item.second;
|
||||||
vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex));
|
vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex));
|
||||||
}
|
}
|
||||||
|
@ -265,8 +266,7 @@ bool BlockManager::LoadBlockIndex(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::pair<int, CBlockIndex*>& item : vSortedByHeight)
|
for (const std::pair<int, CBlockIndex*>& item : vSortedByHeight) {
|
||||||
{
|
|
||||||
if (ShutdownRequested()) return false;
|
if (ShutdownRequested()) return false;
|
||||||
CBlockIndex* pindex = item.second;
|
CBlockIndex* pindex = item.second;
|
||||||
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
|
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
|
||||||
|
@ -329,8 +329,9 @@ bool BlockManager::LoadBlockIndex(
|
||||||
if (pindex->nStatus & BLOCK_FAILED_MASK && (!chainman.m_best_invalid || pindex->nChainWork > chainman.m_best_invalid->nChainWork)) {
|
if (pindex->nStatus & BLOCK_FAILED_MASK && (!chainman.m_best_invalid || pindex->nChainWork > chainman.m_best_invalid->nChainWork)) {
|
||||||
chainman.m_best_invalid = pindex;
|
chainman.m_best_invalid = pindex;
|
||||||
}
|
}
|
||||||
if (pindex->pprev)
|
if (pindex->pprev) {
|
||||||
pindex->BuildSkip();
|
pindex->BuildSkip();
|
||||||
|
}
|
||||||
if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == nullptr || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
|
if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == nullptr || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
|
||||||
pindexBestHeader = pindex;
|
pindexBestHeader = pindex;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +339,8 @@ bool BlockManager::LoadBlockIndex(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockManager::Unload() {
|
void BlockManager::Unload()
|
||||||
|
{
|
||||||
m_blocks_unlinked.clear();
|
m_blocks_unlinked.clear();
|
||||||
|
|
||||||
for (const BlockMap::value_type& entry : m_block_index) {
|
for (const BlockMap::value_type& entry : m_block_index) {
|
||||||
|
@ -380,8 +382,7 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
|
||||||
setBlkDataFiles.insert(pindex->nFile);
|
setBlkDataFiles.insert(pindex->nFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++)
|
for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++) {
|
||||||
{
|
|
||||||
FlatFilePos pos(*it, 0);
|
FlatFilePos pos(*it, 0);
|
||||||
if (CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION).IsNull()) {
|
if (CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION).IsNull()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -390,8 +391,9 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
|
||||||
|
|
||||||
// Check whether we have ever pruned block & undo files
|
// Check whether we have ever pruned block & undo files
|
||||||
m_block_tree_db->ReadFlag("prunedblockfiles", fHavePruned);
|
m_block_tree_db->ReadFlag("prunedblockfiles", fHavePruned);
|
||||||
if (fHavePruned)
|
if (fHavePruned) {
|
||||||
LogPrintf("LoadBlockIndexDB(): Block files have previously been pruned\n");
|
LogPrintf("LoadBlockIndexDB(): Block files have previously been pruned\n");
|
||||||
|
}
|
||||||
|
|
||||||
// Check whether we need to continue reindexing
|
// Check whether we need to continue reindexing
|
||||||
bool fReindexing = false;
|
bool fReindexing = false;
|
||||||
|
@ -405,8 +407,7 @@ CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data)
|
||||||
{
|
{
|
||||||
const MapCheckpoints& checkpoints = data.mapCheckpoints;
|
const MapCheckpoints& checkpoints = data.mapCheckpoints;
|
||||||
|
|
||||||
for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints))
|
for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints)) {
|
||||||
{
|
|
||||||
const uint256& hash = i.second;
|
const uint256& hash = i.second;
|
||||||
CBlockIndex* pindex = LookupBlockIndex(hash);
|
CBlockIndex* pindex = LookupBlockIndex(hash);
|
||||||
if (pindex) {
|
if (pindex) {
|
||||||
|
|
|
@ -50,8 +50,7 @@ extern uint64_t nPruneTarget;
|
||||||
|
|
||||||
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
||||||
|
|
||||||
struct CBlockIndexWorkComparator
|
struct CBlockIndexWorkComparator {
|
||||||
{
|
|
||||||
bool operator()(const CBlockIndex* pa, const CBlockIndex* pb) const;
|
bool operator()(const CBlockIndex* pa, const CBlockIndex* pb) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,7 +123,8 @@ public:
|
||||||
//! Returns last CBlockIndex* that is a checkpoint
|
//! Returns last CBlockIndex* that is a checkpoint
|
||||||
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
~BlockManager() {
|
~BlockManager()
|
||||||
|
{
|
||||||
Unload();
|
Unload();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue