aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-07-01 10:24:58 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-07-15 13:54:09 +0200
commitfaa54e375782b21cbc2761c763128131c569e903 (patch)
treee85e2453bcf35354ad3e672d8411f3a2c6ea9c3e /src/validation.cpp
parentfa27f03b4943540aa2eab283d4cf50ad4a1a01f8 (diff)
downloadbitcoin-faa54e375782b21cbc2761c763128131c569e903.tar.xz
Move pblocktree global to BlockManager
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 6c70fc686b..f81c27e8e3 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -170,8 +170,6 @@ CBlockIndex* BlockManager::FindForkInGlobalIndex(const CChain& chain, const CBlo
return chain.Genesis();
}
-std::unique_ptr<CBlockTreeDB> pblocktree;
-
bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
const CCoinsViewCache& inputs, unsigned int flags, bool cacheSigStore,
bool cacheFullScriptStore, PrecomputedTransactionData& txdata,
@@ -2075,7 +2073,7 @@ bool CChainState::FlushStateToDisk(
if (!setFilesToPrune.empty()) {
fFlushForPrune = true;
if (!fHavePruned) {
- pblocktree->WriteFlag("prunedblockfiles", true);
+ m_blockman.m_block_tree_db->WriteFlag("prunedblockfiles", true);
fHavePruned = true;
}
}
@@ -2127,7 +2125,7 @@ bool CChainState::FlushStateToDisk(
vBlocks.push_back(*it);
setDirtyBlockIndex.erase(it++);
}
- if (!pblocktree->WriteBatchSync(vFiles, nLastBlockFile, vBlocks)) {
+ if (!m_blockman.m_block_tree_db->WriteBatchSync(vFiles, nLastBlockFile, vBlocks)) {
return AbortNode(state, "Failed to write to block index database");
}
}
@@ -3700,11 +3698,11 @@ CBlockIndex * BlockManager::InsertBlockIndex(const uint256& hash)
bool BlockManager::LoadBlockIndex(
const Consensus::Params& consensus_params,
- CBlockTreeDB& blocktree,
std::set<CBlockIndex*, CBlockIndexWorkComparator>& block_index_candidates)
{
- if (!blocktree.LoadBlockIndexGuts(consensus_params, [this](const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return this->InsertBlockIndex(hash); }))
+ if (!m_block_tree_db->LoadBlockIndexGuts(consensus_params, [this](const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return this->InsertBlockIndex(hash); })) {
return false;
+ }
// Calculate nChainWork
std::vector<std::pair<int, CBlockIndex*> > vSortedByHeight;
@@ -3767,22 +3765,22 @@ void BlockManager::Unload() {
bool BlockManager::LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkComparator>& setBlockIndexCandidates)
{
if (!LoadBlockIndex(
- ::Params().GetConsensus(), *pblocktree,
+ ::Params().GetConsensus(),
setBlockIndexCandidates)) {
return false;
}
// Load block file info
- pblocktree->ReadLastBlockFile(nLastBlockFile);
+ m_block_tree_db->ReadLastBlockFile(nLastBlockFile);
vinfoBlockFile.resize(nLastBlockFile + 1);
LogPrintf("%s: last block file = %i\n", __func__, nLastBlockFile);
for (int nFile = 0; nFile <= nLastBlockFile; nFile++) {
- pblocktree->ReadBlockFileInfo(nFile, vinfoBlockFile[nFile]);
+ m_block_tree_db->ReadBlockFileInfo(nFile, vinfoBlockFile[nFile]);
}
LogPrintf("%s: last block file info: %s\n", __func__, vinfoBlockFile[nLastBlockFile].ToString());
for (int nFile = nLastBlockFile + 1; true; nFile++) {
CBlockFileInfo info;
- if (pblocktree->ReadBlockFileInfo(nFile, info)) {
+ if (m_block_tree_db->ReadBlockFileInfo(nFile, info)) {
vinfoBlockFile.push_back(info);
} else {
break;
@@ -3807,13 +3805,13 @@ bool BlockManager::LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkCompar
}
// Check whether we have ever pruned block & undo files
- pblocktree->ReadFlag("prunedblockfiles", fHavePruned);
+ m_block_tree_db->ReadFlag("prunedblockfiles", fHavePruned);
if (fHavePruned)
LogPrintf("LoadBlockIndexDB(): Block files have previously been pruned\n");
// Check whether we need to continue reindexing
bool fReindexing = false;
- pblocktree->ReadReindexing(fReindexing);
+ m_block_tree_db->ReadReindexing(fReindexing);
if(fReindexing) fReindex = true;
return true;