MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / PruneOneBlockFile

Function PruneOneBlockFile

src/main.cpp:3675–3704  ·  view source on GitHub ↗

Prune a block file (modify associated database entries)*/

Source from the content-addressed store, hash-verified

3673
3674/* Prune a block file (modify associated database entries)*/
3675void PruneOneBlockFile(const int fileNumber)
3676{
3677 for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) {
3678 CBlockIndex* pindex = it->second;
3679 if (pindex->nFile == fileNumber) {
3680 pindex->nStatus &= ~BLOCK_HAVE_DATA;
3681 pindex->nStatus &= ~BLOCK_HAVE_UNDO;
3682 pindex->nFile = 0;
3683 pindex->nDataPos = 0;
3684 pindex->nUndoPos = 0;
3685 setDirtyBlockIndex.insert(pindex);
3686
3687 // Prune from mapBlocksUnlinked -- any block we prune would have
3688 // to be downloaded again in order to consider its chain, at which
3689 // point it would be considered as a candidate for
3690 // mapBlocksUnlinked or setBlockIndexCandidates.
3691 std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev);
3692 while (range.first != range.second) {
3693 std::multimap<CBlockIndex *, CBlockIndex *>::iterator it = range.first;
3694 range.first++;
3695 if (it->second == pindex) {
3696 mapBlocksUnlinked.erase(it);
3697 }
3698 }
3699 }
3700 }
3701
3702 vinfoBlockFile[fileNumber].SetNull();
3703 setDirtyFileInfo.insert(fileNumber);
3704}
3705
3706
3707void UnlinkPrunedFiles(std::set<int>& setFilesToPrune)

Callers 1

FindFilesToPruneFunction · 0.85

Calls 5

beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45
SetNullMethod · 0.45

Tested by

no test coverage detected