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

Method PruneOneBlockFile

src/node/blockstorage.cpp:270–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void 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
303void BlockManager::FindFilesToPruneManual(
304 std::set<int>& setFilesToPrune,

Callers 2

BOOST_FIXTURE_TEST_CASEFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80

Calls 3

insertMethod · 0.45
eraseMethod · 0.45
atMethod · 0.45

Tested by 2

BOOST_FIXTURE_TEST_CASEFunction · 0.64
BOOST_FIXTURE_TEST_CASEFunction · 0.64