MCPcopy Create free account
hub / github.com/LUX-Core/lux / FindFilesToPruneManual

Function FindFilesToPruneManual

src/main.cpp:5243–5262  ·  view source on GitHub ↗

Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */

Source from the content-addressed store, hash-verified

5241
5242/* Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */
5243static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight)
5244{
5245 assert(fPruneMode && nManualPruneHeight > 0);
5246
5247 LOCK2(cs_main, cs_LastBlockFile);
5248 if (chainActive.Tip() == nullptr)
5249 return;
5250
5251 // last block to prune is the lesser of (user-specified height, MIN_BLOCKS_TO_KEEP from the tip)
5252 unsigned int nLastBlockWeCanPrune = std::min((unsigned int)nManualPruneHeight, (unsigned int) (chainActive.Height() - MIN_BLOCKS_TO_KEEP));
5253 int count=0;
5254 for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
5255 if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
5256 continue;
5257 PruneOneBlockFile(fileNumber);
5258 setFilesToPrune.insert(fileNumber);
5259 count++;
5260 }
5261 LogPrintf("Prune (Manual): prune_height=%d removed %d blk/rev pairs\n", nLastBlockWeCanPrune, count);
5262}
5263
5264/* Calculate the block/rev files that should be deleted to remain under target*/
5265void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight)

Callers 1

FlushStateToDiskFunction · 0.85

Calls 4

PruneOneBlockFileFunction · 0.85
TipMethod · 0.80
HeightMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected