Prune a block file (modify associated database entries)*/
| 5188 | |
| 5189 | /* Prune a block file (modify associated database entries)*/ |
| 5190 | void PruneOneBlockFile(const int fileNumber) |
| 5191 | { |
| 5192 | for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { |
| 5193 | CBlockIndex* pindex = it->second; |
| 5194 | if (pindex->nFile == fileNumber) { |
| 5195 | pindex->nStatus &= ~BLOCK_HAVE_DATA; |
| 5196 | pindex->nStatus &= ~BLOCK_HAVE_UNDO; |
| 5197 | pindex->nFile = 0; |
| 5198 | pindex->nDataPos = 0; |
| 5199 | pindex->nUndoPos = 0; |
| 5200 | setDirtyBlockIndex.insert(pindex); |
| 5201 | |
| 5202 | // Prune from mapBlocksUnlinked -- any block we prune would have |
| 5203 | // to be downloaded again in order to consider its chain, at which |
| 5204 | // point it would be considered as a candidate for |
| 5205 | // mapBlocksUnlinked or setBlockIndexCandidates. |
| 5206 | std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev); |
| 5207 | while (range.first != range.second) { |
| 5208 | std::multimap<CBlockIndex *, CBlockIndex *>::iterator it = range.first; |
| 5209 | range.first++; |
| 5210 | if (it->second == pindex) { |
| 5211 | mapBlocksUnlinked.erase(it); |
| 5212 | } |
| 5213 | } |
| 5214 | } |
| 5215 | } |
| 5216 | |
| 5217 | vinfoBlockFile[fileNumber].SetNull(); |
| 5218 | setDirtyFileInfo.insert(fileNumber); |
| 5219 | } |
| 5220 | |
| 5221 | |
| 5222 | void UnlinkPrunedFiles(std::set<int>& setFilesToPrune) |