Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */
| 5241 | |
| 5242 | /* Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */ |
| 5243 | static 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*/ |
| 5265 | void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight) |
no test coverage detected