| 268 | } |
| 269 | |
| 270 | void BlockManager::PruneOneBlockFile(const int fileNumber) |
| 271 | { |
| 272 | AssertLockHeld(cs_main); |
| 273 | |
| 274 | for (auto& entry : m_block_index) { |
| 275 | CBlockIndex* pindex = &entry.second; |
| 276 | if (pindex->nFile == fileNumber) { |
| 277 | pindex->nStatus &= ~BLOCK_HAVE_DATA; |
| 278 | pindex->nStatus &= ~BLOCK_HAVE_UNDO; |
| 279 | pindex->nFile = 0; |
| 280 | pindex->nDataPos = 0; |
| 281 | pindex->nUndoPos = 0; |
| 282 | m_dirty_blockindex.insert(pindex); |
| 283 | |
| 284 | // Prune from m_blocks_unlinked -- any block we prune would have |
| 285 | // to be downloaded again in order to consider its chain, at which |
| 286 | // point it would be considered as a candidate for |
| 287 | // m_blocks_unlinked or setBlockIndexCandidates. |
| 288 | auto range = m_blocks_unlinked.equal_range(pindex->pprev); |
| 289 | while (range.first != range.second) { |
| 290 | std::multimap<CBlockIndex*, CBlockIndex*>::iterator _it = range.first; |
| 291 | range.first++; |
| 292 | if (_it->second == pindex) { |
| 293 | m_blocks_unlinked.erase(_it); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | m_blockfile_info.at(fileNumber) = CBlockFileInfo{}; |
| 300 | m_dirty_fileinfo.insert(fileNumber); |
| 301 | } |
| 302 | |
| 303 | void BlockManager::FindFilesToPruneManual( |
| 304 | std::set<int>& setFilesToPrune, |