MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FindFilesToPruneManual

Function FindFilesToPruneManual

src/validation.cpp:3915–3934  ·  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

3913
3914/* Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */
3915static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight)
3916{
3917 assert(fPruneMode && nManualPruneHeight > 0);
3918
3919 LOCK2(cs_main, cs_LastBlockFile);
3920 if (chainActive.Tip() == nullptr)
3921 return;
3922
3923 // last block to prune is the lesser of (user-specified height, MIN_BLOCKS_TO_KEEP from the tip)
3924 unsigned int nLastBlockWeCanPrune = std::min((unsigned)nManualPruneHeight, chainActive.Tip()->nHeight - MIN_BLOCKS_TO_KEEP);
3925 int count=0;
3926 for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
3927 if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
3928 continue;
3929 PruneOneBlockFile(fileNumber);
3930 setFilesToPrune.insert(fileNumber);
3931 count++;
3932 }
3933 LogPrintf("Prune (Manual): prune_height=%d removed %d blk/rev pairs\n", nLastBlockWeCanPrune, count);
3934}
3935
3936/* This function is called from the RPC code for pruneblockchain */
3937void PruneBlockFilesManual(int nManualPruneHeight)

Callers 1

FlushStateToDiskFunction · 0.85

Calls 3

PruneOneBlockFileFunction · 0.85
TipMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected