Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */
| 3913 | |
| 3914 | /* Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */ |
| 3915 | static 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 */ |
| 3937 | void PruneBlockFilesManual(int nManualPruneHeight) |
no test coverage detected