Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,105 Lines • ▼ Show 20 Lines | try { | ||||
bool fFlushForPrune = false; | bool fFlushForPrune = false; | ||||
bool fDoFullFlush = false; | bool fDoFullFlush = false; | ||||
CoinsCacheSizeState cache_state = | CoinsCacheSizeState cache_state = | ||||
GetCoinsCacheSizeState(::g_mempool); | GetCoinsCacheSizeState(::g_mempool); | ||||
LOCK(cs_LastBlockFile); | LOCK(cs_LastBlockFile); | ||||
if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && | if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && | ||||
!fReindex) { | !fReindex) { | ||||
if (nManualPruneHeight > 0) { | if (nManualPruneHeight > 0) { | ||||
LOG_TIME_MILLIS("find files to prune (manual)", | LOG_TIME_MILLIS_WITH_CATEGORY( | ||||
BCLog::BENCH); | "find files to prune (manual)", BCLog::BENCH); | ||||
FindFilesToPruneManual(g_chainman, setFilesToPrune, | FindFilesToPruneManual(g_chainman, setFilesToPrune, | ||||
nManualPruneHeight); | nManualPruneHeight); | ||||
} else { | } else { | ||||
LOG_TIME_MILLIS("find files to prune", BCLog::BENCH); | LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune", | ||||
BCLog::BENCH); | |||||
FindFilesToPrune(g_chainman, setFilesToPrune, | FindFilesToPrune(g_chainman, setFilesToPrune, | ||||
chainparams.PruneAfterHeight()); | chainparams.PruneAfterHeight()); | ||||
fCheckForPruning = false; | fCheckForPruning = false; | ||||
} | } | ||||
if (!setFilesToPrune.empty()) { | if (!setFilesToPrune.empty()) { | ||||
fFlushForPrune = true; | fFlushForPrune = true; | ||||
if (!fHavePruned) { | if (!fHavePruned) { | ||||
pblocktree->WriteFlag("prunedblockfiles", true); | pblocktree->WriteFlag("prunedblockfiles", true); | ||||
Show All 33 Lines | try { | ||||
if (fDoFullFlush || fPeriodicWrite) { | if (fDoFullFlush || fPeriodicWrite) { | ||||
// Depend on nMinDiskSpace to ensure we can write block index | // Depend on nMinDiskSpace to ensure we can write block index | ||||
if (!CheckDiskSpace(GetBlocksDir())) { | if (!CheckDiskSpace(GetBlocksDir())) { | ||||
return AbortNode(state, "Disk space is too low!", | return AbortNode(state, "Disk space is too low!", | ||||
_("Disk space is too low!")); | _("Disk space is too low!")); | ||||
} | } | ||||
{ | { | ||||
LOG_TIME_MILLIS("write block and undo data to disk", | LOG_TIME_MILLIS_WITH_CATEGORY( | ||||
BCLog::BENCH); | "write block and undo data to disk", BCLog::BENCH); | ||||
// First make sure all block and undo data is flushed to | // First make sure all block and undo data is flushed to | ||||
// disk. | // disk. | ||||
FlushBlockFile(); | FlushBlockFile(); | ||||
} | } | ||||
// Then update all block file information (which may refer to | // Then update all block file information (which may refer to | ||||
// block and undo files). | // block and undo files). | ||||
{ | { | ||||
LOG_TIME_MILLIS("write block index to disk", BCLog::BENCH); | LOG_TIME_MILLIS_WITH_CATEGORY("write block index to disk", | ||||
BCLog::BENCH); | |||||
std::vector<std::pair<int, const CBlockFileInfo *>> vFiles; | std::vector<std::pair<int, const CBlockFileInfo *>> vFiles; | ||||
vFiles.reserve(setDirtyFileInfo.size()); | vFiles.reserve(setDirtyFileInfo.size()); | ||||
for (int i : setDirtyFileInfo) { | for (int i : setDirtyFileInfo) { | ||||
vFiles.push_back(std::make_pair(i, &vinfoBlockFile[i])); | vFiles.push_back(std::make_pair(i, &vinfoBlockFile[i])); | ||||
} | } | ||||
setDirtyFileInfo.clear(); | setDirtyFileInfo.clear(); | ||||
Show All 10 Lines | try { | ||||
vBlocks)) { | vBlocks)) { | ||||
return AbortNode( | return AbortNode( | ||||
state, "Failed to write to block index database"); | state, "Failed to write to block index database"); | ||||
} | } | ||||
} | } | ||||
// Finally remove any pruned files | // Finally remove any pruned files | ||||
if (fFlushForPrune) { | if (fFlushForPrune) { | ||||
LOG_TIME_MILLIS("unlink pruned files", BCLog::BENCH); | LOG_TIME_MILLIS_WITH_CATEGORY("unlink pruned files", | ||||
BCLog::BENCH); | |||||
UnlinkPrunedFiles(setFilesToPrune); | UnlinkPrunedFiles(setFilesToPrune); | ||||
} | } | ||||
nLastWrite = nNow; | nLastWrite = nNow; | ||||
} | } | ||||
// Flush best chain related state. This can only be done if the | // Flush best chain related state. This can only be done if the | ||||
// blocks / block index write was also done. | // blocks / block index write was also done. | ||||
if (fDoFullFlush && !CoinsTip().GetBestBlock().IsNull()) { | if (fDoFullFlush && !CoinsTip().GetBestBlock().IsNull()) { | ||||
▲ Show 20 Lines • Show All 3,852 Lines • Show Last 20 Lines |