diff options
author | Carl Dong <contact@carldong.me> | 2020-08-25 19:05:50 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2020-09-15 14:13:44 -0400 |
commit | f8d4975ab3fcd3553843cf0862251289c88c106b (patch) | |
tree | fc52dc628f532971eb04873acd483aa5f19f831d /src/validation.cpp | |
parent | 74f73c783d46b012f375d819e2cd09c792820cd5 (diff) |
validation: Move PruneOneBlockFile to BlockManager
[META] This is a pure refactor commit.
Move PruneBlockFile to BlockManager because:
1. PruneOneBlockFile only acts on BlockManager
2. Eliminates the need for callers (FindFilesToPrune{,Manual}) to have a
reference to the larger ChainstateManager, just a reference to
BlockManager is enough. See following commits.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 7478fb5510..76f8bcba7f 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3912,12 +3912,12 @@ uint64_t CalculateCurrentUsage() return retval; } -void ChainstateManager::PruneOneBlockFile(const int fileNumber) +void BlockManager::PruneOneBlockFile(const int fileNumber) { AssertLockHeld(cs_main); LOCK(cs_LastBlockFile); - for (const auto& entry : m_blockman.m_block_index) { + for (const auto& entry : m_block_index) { CBlockIndex* pindex = entry.second; if (pindex->nFile == fileNumber) { pindex->nStatus &= ~BLOCK_HAVE_DATA; @@ -3931,12 +3931,12 @@ void ChainstateManager::PruneOneBlockFile(const int fileNumber) // to be downloaded again in order to consider its chain, at which // point it would be considered as a candidate for // m_blocks_unlinked or setBlockIndexCandidates. - auto range = m_blockman.m_blocks_unlinked.equal_range(pindex->pprev); + auto range = m_blocks_unlinked.equal_range(pindex->pprev); while (range.first != range.second) { std::multimap<CBlockIndex *, CBlockIndex *>::iterator _it = range.first; range.first++; if (_it->second == pindex) { - m_blockman.m_blocks_unlinked.erase(_it); + m_blocks_unlinked.erase(_it); } } } @@ -3972,7 +3972,7 @@ static void FindFilesToPruneManual(ChainstateManager& chainman, std::set<int>& s for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) { if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) continue; - chainman.PruneOneBlockFile(fileNumber); + chainman.m_blockman.PruneOneBlockFile(fileNumber); setFilesToPrune.insert(fileNumber); count++; } @@ -4047,7 +4047,7 @@ static void FindFilesToPrune(ChainstateManager& chainman, std::set<int>& setFile if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) continue; - chainman.PruneOneBlockFile(fileNumber); + chainman.m_blockman.PruneOneBlockFile(fileNumber); // Queue up the files for removal setFilesToPrune.insert(fileNumber); nCurrentUsage -= nBytesToPrune; |