Prune a block file (modify associated database entries)*/
| 3868 | |
| 3869 | /* Prune a block file (modify associated database entries)*/ |
| 3870 | void PruneOneBlockFile(const int fileNumber) |
| 3871 | { |
| 3872 | LOCK(cs_LastBlockFile); |
| 3873 | |
| 3874 | for (const auto& entry : mapBlockIndex) { |
| 3875 | CBlockIndex* pindex = entry.second; |
| 3876 | if (pindex->nFile == fileNumber) { |
| 3877 | pindex->nStatus &= ~BLOCK_HAVE_DATA; |
| 3878 | pindex->nStatus &= ~BLOCK_HAVE_UNDO; |
| 3879 | pindex->nFile = 0; |
| 3880 | pindex->nDataPos = 0; |
| 3881 | pindex->nUndoPos = 0; |
| 3882 | setDirtyBlockIndex.insert(pindex); |
| 3883 | |
| 3884 | // Prune from mapBlocksUnlinked -- any block we prune would have |
| 3885 | // to be downloaded again in order to consider its chain, at which |
| 3886 | // point it would be considered as a candidate for |
| 3887 | // mapBlocksUnlinked or setBlockIndexCandidates. |
| 3888 | std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev); |
| 3889 | while (range.first != range.second) { |
| 3890 | std::multimap<CBlockIndex *, CBlockIndex *>::iterator _it = range.first; |
| 3891 | range.first++; |
| 3892 | if (_it->second == pindex) { |
| 3893 | mapBlocksUnlinked.erase(_it); |
| 3894 | } |
| 3895 | } |
| 3896 | } |
| 3897 | } |
| 3898 | |
| 3899 | vinfoBlockFile[fileNumber].SetNull(); |
| 3900 | setDirtyFileInfo.insert(fileNumber); |
| 3901 | } |
| 3902 | |
| 3903 | |
| 3904 | void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune) |