mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
move-mostly: Make fHavePruned a BlockMan member
[META] In the next commit, we move the clearing of fHavePruned to
BlockManager::Unload()
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
namespace node {
|
||||
std::atomic_bool fImporting(false);
|
||||
std::atomic_bool fReindex(false);
|
||||
bool fHavePruned = false;
|
||||
bool fPruneMode = false;
|
||||
uint64_t nPruneTarget = 0;
|
||||
|
||||
@@ -390,7 +389,7 @@ const CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool IsBlockPruned(const CBlockIndex* pblockindex)
|
||||
bool BlockManager::IsBlockPruned(const CBlockIndex* pblockindex)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
return (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0);
|
||||
|
||||
@@ -45,8 +45,6 @@ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
|
||||
extern std::atomic_bool fImporting;
|
||||
extern std::atomic_bool fReindex;
|
||||
/** Pruning-related variables and constants */
|
||||
/** True if any block files have ever been pruned. */
|
||||
extern bool fHavePruned;
|
||||
/** True if we're running in -prune mode. */
|
||||
extern bool fPruneMode;
|
||||
/** Number of MiB of block files that we're trying to stay below. */
|
||||
@@ -171,15 +169,18 @@ public:
|
||||
//! Returns last CBlockIndex* that is a checkpoint
|
||||
const CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
/** True if any block files have ever been pruned. */
|
||||
bool fHavePruned = false;
|
||||
|
||||
//! Check whether the block associated with this index entry is pruned or not.
|
||||
bool IsBlockPruned(const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
~BlockManager()
|
||||
{
|
||||
Unload();
|
||||
}
|
||||
};
|
||||
|
||||
//! Check whether the block associated with this index entry is pruned or not.
|
||||
bool IsBlockPruned(const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
void CleanupBlockRevFiles();
|
||||
|
||||
/** Open a block file (blk?????.dat) */
|
||||
|
||||
@@ -65,7 +65,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
||||
|
||||
// Check for changed -prune state. What we are concerned about is a user who has pruned blocks
|
||||
// in the past, but is now trying to run unpruned.
|
||||
if (fHavePruned && !fPruneMode) {
|
||||
if (chainman.m_blockman.fHavePruned && !fPruneMode) {
|
||||
return ChainstateLoadingError::ERROR_PRUNED_NEEDS_REINDEX;
|
||||
}
|
||||
|
||||
|
||||
@@ -645,7 +645,7 @@ public:
|
||||
bool havePruned() override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
return node::fHavePruned;
|
||||
return m_node.chainman->m_blockman.fHavePruned;
|
||||
}
|
||||
bool isReadyToBroadcast() override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload(); }
|
||||
bool isInitialBlockDownload() override {
|
||||
|
||||
Reference in New Issue
Block a user