Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,330 Lines • ▼ Show 20 Lines | CBlockIndex *InsertBlockIndex(uint256 hash) { | ||||
} | } | ||||
mi = mapBlockIndex.insert(std::make_pair(hash, pindexNew)).first; | mi = mapBlockIndex.insert(std::make_pair(hash, pindexNew)).first; | ||||
pindexNew->phashBlock = &((*mi).first); | pindexNew->phashBlock = &((*mi).first); | ||||
return pindexNew; | return pindexNew; | ||||
} | } | ||||
static bool LoadBlockIndexDB(const CChainParams &chainparams) { | static bool LoadBlockIndexDB(const Config &config) { | ||||
if (!pblocktree->LoadBlockIndexGuts(InsertBlockIndex)) { | if (!pblocktree->LoadBlockIndexGuts(config, InsertBlockIndex)) { | ||||
return false; | return false; | ||||
} | } | ||||
boost::this_thread::interruption_point(); | boost::this_thread::interruption_point(); | ||||
// Calculate nChainWork | // Calculate nChainWork | ||||
std::vector<std::pair<int, CBlockIndex *>> vSortedByHeight; | std::vector<std::pair<int, CBlockIndex *>> vSortedByHeight; | ||||
vSortedByHeight.reserve(mapBlockIndex.size()); | vSortedByHeight.reserve(mapBlockIndex.size()); | ||||
▲ Show 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | void UnloadBlockIndex() { | ||||
for (BlockMap::value_type &entry : mapBlockIndex) { | for (BlockMap::value_type &entry : mapBlockIndex) { | ||||
delete entry.second; | delete entry.second; | ||||
} | } | ||||
mapBlockIndex.clear(); | mapBlockIndex.clear(); | ||||
fHavePruned = false; | fHavePruned = false; | ||||
} | } | ||||
bool LoadBlockIndex(const CChainParams &chainparams) { | bool LoadBlockIndex(const Config &config) { | ||||
// Load block index from databases | // Load block index from databases | ||||
if (!fReindex && !LoadBlockIndexDB(chainparams)) { | if (!fReindex && !LoadBlockIndexDB(config)) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool InitBlockIndex(const Config &config) { | bool InitBlockIndex(const Config &config) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
▲ Show 20 Lines • Show All 682 Lines • Show Last 20 Lines |