Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,291 Lines • ▼ Show 20 Lines | static void FindFilesToPrune(std::set<int> &setFilesToPrune, | ||||
// We don't check to prune until after we've allocated new space for files, | // We don't check to prune until after we've allocated new space for files, | ||||
// so we should leave a buffer under our target to account for another | // so we should leave a buffer under our target to account for another | ||||
// allocation before the next pruning. | // allocation before the next pruning. | ||||
uint64_t nBuffer = BLOCKFILE_CHUNK_SIZE + UNDOFILE_CHUNK_SIZE; | uint64_t nBuffer = BLOCKFILE_CHUNK_SIZE + UNDOFILE_CHUNK_SIZE; | ||||
uint64_t nBytesToPrune; | uint64_t nBytesToPrune; | ||||
int count = 0; | int count = 0; | ||||
if (nCurrentUsage + nBuffer >= nPruneTarget) { | if (nCurrentUsage + nBuffer >= nPruneTarget) { | ||||
// On a prune event, the chainstate DB is flushed. | |||||
// To avoid excessive prune events negating the benefit of high dbcache | |||||
// values, we should not prune too rapidly. | |||||
// So when pruning in IBD, increase the buffer a bit to avoid a re-prune | |||||
// too soon. | |||||
if (IsInitialBlockDownload()) { | |||||
// Since this is only relevant during IBD, we use a fixed 10% | |||||
nBuffer += nPruneTarget / 10; | |||||
} | |||||
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) { | for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) { | ||||
nBytesToPrune = vinfoBlockFile[fileNumber].nSize + | nBytesToPrune = vinfoBlockFile[fileNumber].nSize + | ||||
vinfoBlockFile[fileNumber].nUndoSize; | vinfoBlockFile[fileNumber].nUndoSize; | ||||
if (vinfoBlockFile[fileNumber].nSize == 0) { | if (vinfoBlockFile[fileNumber].nSize == 0) { | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,379 Lines • Show Last 20 Lines |