|
|
@ -196,8 +196,8 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
|
|
|
|
std::unique_ptr<CBlockTreeDB> pblocktree;
|
|
|
|
std::unique_ptr<CBlockTreeDB> pblocktree;
|
|
|
|
|
|
|
|
|
|
|
|
// See definition for documentation
|
|
|
|
// See definition for documentation
|
|
|
|
static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight);
|
|
|
|
static void FindFilesToPruneManual(ChainstateManager& chainman, std::set<int>& setFilesToPrune, int nManualPruneHeight);
|
|
|
|
static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight);
|
|
|
|
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);
|
|
|
|
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 FILE* OpenUndoFile(const FlatFilePos &pos, bool fReadOnly = false);
|
|
|
|
static FlatFileSeq BlockFileSeq();
|
|
|
|
static FlatFileSeq BlockFileSeq();
|
|
|
@ -2282,11 +2282,11 @@ bool CChainState::FlushStateToDisk(
|
|
|
|
if (nManualPruneHeight > 0) {
|
|
|
|
if (nManualPruneHeight > 0) {
|
|
|
|
LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune (manual)", BCLog::BENCH);
|
|
|
|
LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune (manual)", BCLog::BENCH);
|
|
|
|
|
|
|
|
|
|
|
|
FindFilesToPruneManual(setFilesToPrune, nManualPruneHeight);
|
|
|
|
FindFilesToPruneManual(g_chainman, setFilesToPrune, nManualPruneHeight);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune", BCLog::BENCH);
|
|
|
|
LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune", BCLog::BENCH);
|
|
|
|
|
|
|
|
|
|
|
|
FindFilesToPrune(setFilesToPrune, chainparams.PruneAfterHeight());
|
|
|
|
FindFilesToPrune(g_chainman, setFilesToPrune, chainparams.PruneAfterHeight());
|
|
|
|
fCheckForPruning = false;
|
|
|
|
fCheckForPruning = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!setFilesToPrune.empty()) {
|
|
|
|
if (!setFilesToPrune.empty()) {
|
|
|
@ -3895,12 +3895,12 @@ uint64_t CalculateCurrentUsage()
|
|
|
|
return retval;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Prune a block file (modify associated database entries)*/
|
|
|
|
void ChainstateManager::PruneOneBlockFile(const int fileNumber)
|
|
|
|
void PruneOneBlockFile(const int fileNumber)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
AssertLockHeld(cs_main);
|
|
|
|
LOCK(cs_LastBlockFile);
|
|
|
|
LOCK(cs_LastBlockFile);
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& entry : g_chainman.BlockIndex()) {
|
|
|
|
for (const auto& entry : m_blockman.m_block_index) {
|
|
|
|
CBlockIndex* pindex = entry.second;
|
|
|
|
CBlockIndex* pindex = entry.second;
|
|
|
|
if (pindex->nFile == fileNumber) {
|
|
|
|
if (pindex->nFile == fileNumber) {
|
|
|
|
pindex->nStatus &= ~BLOCK_HAVE_DATA;
|
|
|
|
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
|
|
|
|
// to be downloaded again in order to consider its chain, at which
|
|
|
|
// point it would be considered as a candidate for
|
|
|
|
// point it would be considered as a candidate for
|
|
|
|
// m_blocks_unlinked or setBlockIndexCandidates.
|
|
|
|
// 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) {
|
|
|
|
while (range.first != range.second) {
|
|
|
|
std::multimap<CBlockIndex *, CBlockIndex *>::iterator _it = range.first;
|
|
|
|
std::multimap<CBlockIndex *, CBlockIndex *>::iterator _it = range.first;
|
|
|
|
range.first++;
|
|
|
|
range.first++;
|
|
|
|
if (_it->second == pindex) {
|
|
|
|
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 */
|
|
|
|
/* 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);
|
|
|
|
assert(fPruneMode && nManualPruneHeight > 0);
|
|
|
|
|
|
|
|
|
|
|
@ -3955,7 +3955,7 @@ static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPr
|
|
|
|
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
|
|
|
|
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
|
|
|
|
if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
|
|
|
|
if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
PruneOneBlockFile(fileNumber);
|
|
|
|
chainman.PruneOneBlockFile(fileNumber);
|
|
|
|
setFilesToPrune.insert(fileNumber);
|
|
|
|
setFilesToPrune.insert(fileNumber);
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3988,7 +3988,7 @@ void PruneBlockFilesManual(int nManualPruneHeight)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param[out] setFilesToPrune The set of file indices that can be unlinked will be returned
|
|
|
|
* @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);
|
|
|
|
LOCK2(cs_main, cs_LastBlockFile);
|
|
|
|
if (::ChainActive().Tip() == nullptr || nPruneTarget == 0) {
|
|
|
|
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)
|
|
|
|
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
PruneOneBlockFile(fileNumber);
|
|
|
|
chainman.PruneOneBlockFile(fileNumber);
|
|
|
|
// Queue up the files for removal
|
|
|
|
// Queue up the files for removal
|
|
|
|
setFilesToPrune.insert(fileNumber);
|
|
|
|
setFilesToPrune.insert(fileNumber);
|
|
|
|
nCurrentUsage -= nBytesToPrune;
|
|
|
|
nCurrentUsage -= nBytesToPrune;
|
|
|
|