|
|
|
@ -196,8 +196,8 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
|
|
|
|
|
std::unique_ptr<CBlockTreeDB> pblocktree;
|
|
|
|
|
|
|
|
|
|
// See definition for documentation
|
|
|
|
|
static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight);
|
|
|
|
|
static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight);
|
|
|
|
|
static void FindFilesToPruneManual(ChainstateManager& chainman, std::set<int>& setFilesToPrune, int nManualPruneHeight);
|
|
|
|
|
static void FindFilesToPrune(ChainstateManager& chainman, std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight);
|
|
|
|
|
bool CheckInputScripts(const CTransaction& tx, TxValidationState &state, const CCoinsViewCache &inputs, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, std::vector<CScriptCheck> *pvChecks = nullptr);
|
|
|
|
|
static FILE* OpenUndoFile(const FlatFilePos &pos, bool fReadOnly = false);
|
|
|
|
|
static FlatFileSeq BlockFileSeq();
|
|
|
|
@ -2282,11 +2282,11 @@ bool CChainState::FlushStateToDisk(
|
|
|
|
|
if (nManualPruneHeight > 0) {
|
|
|
|
|
LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune (manual)", BCLog::BENCH);
|
|
|
|
|
|
|
|
|
|
FindFilesToPruneManual(setFilesToPrune, nManualPruneHeight);
|
|
|
|
|
FindFilesToPruneManual(g_chainman, setFilesToPrune, nManualPruneHeight);
|
|
|
|
|
} else {
|
|
|
|
|
LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune", BCLog::BENCH);
|
|
|
|
|
|
|
|
|
|
FindFilesToPrune(setFilesToPrune, chainparams.PruneAfterHeight());
|
|
|
|
|
FindFilesToPrune(g_chainman, setFilesToPrune, chainparams.PruneAfterHeight());
|
|
|
|
|
fCheckForPruning = false;
|
|
|
|
|
}
|
|
|
|
|
if (!setFilesToPrune.empty()) {
|
|
|
|
@ -3895,12 +3895,12 @@ uint64_t CalculateCurrentUsage()
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Prune a block file (modify associated database entries)*/
|
|
|
|
|
void PruneOneBlockFile(const int fileNumber)
|
|
|
|
|
void ChainstateManager::PruneOneBlockFile(const int fileNumber)
|
|
|
|
|
{
|
|
|
|
|
AssertLockHeld(cs_main);
|
|
|
|
|
LOCK(cs_LastBlockFile);
|
|
|
|
|
|
|
|
|
|
for (const auto& entry : g_chainman.BlockIndex()) {
|
|
|
|
|
for (const auto& entry : m_blockman.m_block_index) {
|
|
|
|
|
CBlockIndex* pindex = entry.second;
|
|
|
|
|
if (pindex->nFile == fileNumber) {
|
|
|
|
|
pindex->nStatus &= ~BLOCK_HAVE_DATA;
|
|
|
|
@ -3914,12 +3914,12 @@ void 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 = g_chainman.m_blockman.m_blocks_unlinked.equal_range(pindex->pprev);
|
|
|
|
|
auto range = m_blockman.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) {
|
|
|
|
|
g_chainman.m_blockman.m_blocks_unlinked.erase(_it);
|
|
|
|
|
m_blockman.m_blocks_unlinked.erase(_it);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -3941,7 +3941,7 @@ void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */
|
|
|
|
|
static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight)
|
|
|
|
|
static void FindFilesToPruneManual(ChainstateManager& chainman, std::set<int>& setFilesToPrune, int nManualPruneHeight)
|
|
|
|
|
{
|
|
|
|
|
assert(fPruneMode && nManualPruneHeight > 0);
|
|
|
|
|
|
|
|
|
@ -3955,7 +3955,7 @@ static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPr
|
|
|
|
|
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
|
|
|
|
|
if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
|
|
|
|
|
continue;
|
|
|
|
|
PruneOneBlockFile(fileNumber);
|
|
|
|
|
chainman.PruneOneBlockFile(fileNumber);
|
|
|
|
|
setFilesToPrune.insert(fileNumber);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
@ -3988,7 +3988,7 @@ void PruneBlockFilesManual(int nManualPruneHeight)
|
|
|
|
|
*
|
|
|
|
|
* @param[out] setFilesToPrune The set of file indices that can be unlinked will be returned
|
|
|
|
|
*/
|
|
|
|
|
static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight)
|
|
|
|
|
static void FindFilesToPrune(ChainstateManager& chainman, std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight)
|
|
|
|
|
{
|
|
|
|
|
LOCK2(cs_main, cs_LastBlockFile);
|
|
|
|
|
if (::ChainActive().Tip() == nullptr || nPruneTarget == 0) {
|
|
|
|
@ -4030,7 +4030,7 @@ static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfte
|
|
|
|
|
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
PruneOneBlockFile(fileNumber);
|
|
|
|
|
chainman.PruneOneBlockFile(fileNumber);
|
|
|
|
|
// Queue up the files for removal
|
|
|
|
|
setFilesToPrune.insert(fileNumber);
|
|
|
|
|
nCurrentUsage -= nBytesToPrune;
|
|
|
|
|