Merge bitcoin/bitcoin#26900: refactor: Add BlockManager getters

faf7b4f1fc Add BlockManager::IsPruneMode() (MarcoFalke)
fae71fe27e Add BlockManager::GetPruneTarget() (MarcoFalke)
fa0f0436d8 Add BlockManager::LoadingBlocks() (MarcoFalke)

Pull request description:

  Requested in https://github.com/bitcoin/bitcoin/pull/25781#discussion_r1061323795, but adding getters seems unrelated from removing globals, so I split it out for now.

ACKs for top commit:
  dergoegge:
    Code review ACK faf7b4f1fc
  brunoerg:
    crACK faf7b4f1fc

Tree-SHA512: 204d0e9a0e8b78175482f89b4ce620fba0e65d8e49ad845d187af44d3843f4c733a01bac1ffe5a5319f524d8346123693a456778b69d6c75268c447eb8839642
This commit is contained in:
MarcoFalke committed 2023-01-27 17:33:11 +01:00
commit 9a288430df
9 files changed
+53 -45

No files matched your search

+3 -2
View File
@@ -415,8 +415,9 @@ IndexSummary BaseIndex::GetSummary() const
return summary; return summary;
} }
void BaseIndex::SetBestBlockIndex(const CBlockIndex* block) { void BaseIndex::SetBestBlockIndex(const CBlockIndex* block)
assert(!node::fPruneMode || AllowPrune()); {
assert(!m_chainstate->m_blockman.IsPruneMode() || AllowPrune());
if (AllowPrune() && block) { if (AllowPrune() && block) {
node::PruneLockInfo prune_lock; node::PruneLockInfo prune_lock;
+6 -4
View File
@@ -1499,7 +1499,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
options.mempool = Assert(node.mempool.get()); options.mempool = Assert(node.mempool.get());
options.reindex = node::fReindex; options.reindex = node::fReindex;
options.reindex_chainstate = fReindexChainState; options.reindex_chainstate = fReindexChainState;
options.prune = node::fPruneMode; options.prune = chainman.m_blockman.IsPruneMode();
options.check_blocks = args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS); options.check_blocks = args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS);
options.check_level = args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL); options.check_level = args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL);
options.check_interrupt = ShutdownRequested; options.check_interrupt = ShutdownRequested;
@@ -1609,7 +1609,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// if pruning, perform the initial blockstore prune // if pruning, perform the initial blockstore prune
// after any wallet rescanning has taken place. // after any wallet rescanning has taken place.
if (fPruneMode) { if (chainman.m_blockman.IsPruneMode()) {
if (!fReindex) { if (!fReindex) {
LOCK(cs_main); LOCK(cs_main);
for (Chainstate* chainstate : chainman.GetAll()) { for (Chainstate* chainstate : chainman.GetAll()) {
@@ -1637,8 +1637,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// On first startup, warn on low block storage space // On first startup, warn on low block storage space
if (!fReindex && !fReindexChainState && chain_active_height <= 1) { if (!fReindex && !fReindexChainState && chain_active_height <= 1) {
uint64_t additional_bytes_needed = fPruneMode ? nPruneTarget uint64_t additional_bytes_needed{
: chainparams.AssumedBlockchainSize() * 1024 * 1024 * 1024; chainman.m_blockman.IsPruneMode() ?
chainman.m_blockman.GetPruneTarget() :
chainparams.AssumedBlockchainSize() * 1024 * 1024 * 1024};
if (!CheckDiskSpace(args.GetBlocksDirPath(), additional_bytes_needed)) { if (!CheckDiskSpace(args.GetBlocksDirPath(), additional_bytes_needed)) {
InitWarning(strprintf(_( InitWarning(strprintf(_(
+10 -15
View File
@@ -53,9 +53,6 @@
using node::ReadBlockFromDisk; using node::ReadBlockFromDisk;
using node::ReadRawBlockFromDisk; using node::ReadRawBlockFromDisk;
using node::fImporting;
using node::fPruneMode;
using node::fReindex;
/** How long to cache transactions in mapRelay for normal relay */ /** How long to cache transactions in mapRelay for normal relay */
static constexpr auto RELAY_TX_CACHE_TIME = 15min; static constexpr auto RELAY_TX_CACHE_TIME = 15min;
@@ -1739,8 +1736,7 @@ bool PeerManagerImpl::BlockRequestAllowed(const CBlockIndex* pindex)
std::optional<std::string> PeerManagerImpl::FetchBlock(NodeId peer_id, const CBlockIndex& block_index) std::optional<std::string> PeerManagerImpl::FetchBlock(NodeId peer_id, const CBlockIndex& block_index)
{ {
if (fImporting) return "Importing..."; if (m_chainman.m_blockman.LoadingBlocks()) return "Loading blocks ...";
if (fReindex) return "Reindexing...";
// Ensure this peer exists and hasn't been disconnected // Ensure this peer exists and hasn't been disconnected
PeerRef peer = GetPeerRef(peer_id); PeerRef peer = GetPeerRef(peer_id);
@@ -3697,7 +3693,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId()); LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
UpdateBlockAvailability(pfrom.GetId(), inv.hash); UpdateBlockAvailability(pfrom.GetId(), inv.hash);
if (!fAlreadyHave && !fImporting && !fReindex && !IsBlockRequested(inv.hash)) { if (!fAlreadyHave && !m_chainman.m_blockman.LoadingBlocks() && !IsBlockRequested(inv.hash)) {
// Headers-first is the primary method of announcement on // Headers-first is the primary method of announcement on
// the network. If a node fell back to sending blocks by // the network. If a node fell back to sending blocks by
// inv, it may be for a re-org, or because we haven't // inv, it may be for a re-org, or because we haven't
@@ -3830,8 +3826,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// If pruning, don't inv blocks unless we have on disk and are likely to still have // If pruning, don't inv blocks unless we have on disk and are likely to still have
// for some reasonable time window (1 hour) that block relay might require. // for some reasonable time window (1 hour) that block relay might require.
const int nPrunedBlocksLikelyToHave = MIN_BLOCKS_TO_KEEP - 3600 / m_chainparams.GetConsensus().nPowTargetSpacing; const int nPrunedBlocksLikelyToHave = MIN_BLOCKS_TO_KEEP - 3600 / m_chainparams.GetConsensus().nPowTargetSpacing;
if (fPruneMode && (!(pindex->nStatus & BLOCK_HAVE_DATA) || pindex->nHeight <= m_chainman.ActiveChain().Tip()->nHeight - nPrunedBlocksLikelyToHave)) if (m_chainman.m_blockman.IsPruneMode() && (!(pindex->nStatus & BLOCK_HAVE_DATA) || pindex->nHeight <= m_chainman.ActiveChain().Tip()->nHeight - nPrunedBlocksLikelyToHave)) {
{
LogPrint(BCLog::NET, " getblocks stopping, pruned or too old block at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); LogPrint(BCLog::NET, " getblocks stopping, pruned or too old block at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
break; break;
} }
@@ -3907,7 +3902,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
return; return;
} }
if (fImporting || fReindex) { if (m_chainman.m_blockman.LoadingBlocks()) {
LogPrint(BCLog::NET, "Ignoring getheaders from peer=%d while importing/reindexing\n", pfrom.GetId()); LogPrint(BCLog::NET, "Ignoring getheaders from peer=%d while importing/reindexing\n", pfrom.GetId());
return; return;
} }
@@ -4186,7 +4181,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
if (msg_type == NetMsgType::CMPCTBLOCK) if (msg_type == NetMsgType::CMPCTBLOCK)
{ {
// Ignore cmpctblock received while importing // Ignore cmpctblock received while importing
if (fImporting || fReindex) { if (m_chainman.m_blockman.LoadingBlocks()) {
LogPrint(BCLog::NET, "Unexpected cmpctblock message received from peer %d\n", pfrom.GetId()); LogPrint(BCLog::NET, "Unexpected cmpctblock message received from peer %d\n", pfrom.GetId());
return; return;
} }
@@ -4402,7 +4397,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
if (msg_type == NetMsgType::BLOCKTXN) if (msg_type == NetMsgType::BLOCKTXN)
{ {
// Ignore blocktxn received while importing // Ignore blocktxn received while importing
if (fImporting || fReindex) { if (m_chainman.m_blockman.LoadingBlocks()) {
LogPrint(BCLog::NET, "Unexpected blocktxn message received from peer %d\n", pfrom.GetId()); LogPrint(BCLog::NET, "Unexpected blocktxn message received from peer %d\n", pfrom.GetId());
return; return;
} }
@@ -4477,7 +4472,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
if (msg_type == NetMsgType::HEADERS) if (msg_type == NetMsgType::HEADERS)
{ {
// Ignore headers received while importing // Ignore headers received while importing
if (fImporting || fReindex) { if (m_chainman.m_blockman.LoadingBlocks()) {
LogPrint(BCLog::NET, "Unexpected headers message received from peer %d\n", pfrom.GetId()); LogPrint(BCLog::NET, "Unexpected headers message received from peer %d\n", pfrom.GetId());
return; return;
} }
@@ -4522,7 +4517,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
if (msg_type == NetMsgType::BLOCK) if (msg_type == NetMsgType::BLOCK)
{ {
// Ignore block received while importing // Ignore block received while importing
if (fImporting || fReindex) { if (m_chainman.m_blockman.LoadingBlocks()) {
LogPrint(BCLog::NET, "Unexpected block message received from peer %d\n", pfrom.GetId()); LogPrint(BCLog::NET, "Unexpected block message received from peer %d\n", pfrom.GetId());
return; return;
} }
@@ -5109,7 +5104,7 @@ void PeerManagerImpl::CheckForStaleTipAndEvictPeers()
if (now > m_stale_tip_check_time) { if (now > m_stale_tip_check_time) {
// Check whether our tip is stale, and if so, allow using an extra // Check whether our tip is stale, and if so, allow using an extra
// outbound peer // outbound peer
if (!fImporting && !fReindex && m_connman.GetNetworkActive() && m_connman.GetUseAddrmanOutgoing() && TipMayBeStale()) { if (!m_chainman.m_blockman.LoadingBlocks() && m_connman.GetNetworkActive() && m_connman.GetUseAddrmanOutgoing() && TipMayBeStale()) {
LogPrintf("Potential stale tip detected, will try using extra outbound peer (last tip update: %d seconds ago)\n", LogPrintf("Potential stale tip detected, will try using extra outbound peer (last tip update: %d seconds ago)\n",
count_seconds(now - m_last_tip_update.load())); count_seconds(now - m_last_tip_update.load()));
m_connman.SetTryNewOutboundPeer(true); m_connman.SetTryNewOutboundPeer(true);
@@ -5416,7 +5411,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
} }
} }
if (!state.fSyncStarted && CanServeBlocks(*peer) && !fImporting && !fReindex) { if (!state.fSyncStarted && CanServeBlocks(*peer) && !m_chainman.m_blockman.LoadingBlocks()) {
// Only actively request headers from a single peer, unless we're close to today. // Only actively request headers from a single peer, unless we're close to today.
if ((nSyncStarted == 0 && sync_blocks_and_headers_from_peer) || m_chainman.m_best_header->Time() > GetAdjustedTime() - 24h) { if ((nSyncStarted == 0 && sync_blocks_and_headers_from_peer) || m_chainman.m_best_header->Time() > GetAdjustedTime() - 24h) {
const CBlockIndex* pindexStart = m_chainman.m_best_header; const CBlockIndex* pindexStart = m_chainman.m_best_header;
+11 -3
View File
@@ -48,10 +48,7 @@ static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE = CMessageHeader::MESSAG
extern std::atomic_bool fImporting; extern std::atomic_bool fImporting;
extern std::atomic_bool fReindex; extern std::atomic_bool fReindex;
/** Pruning-related variables and constants */
/** True if we're running in -prune mode. */
extern bool fPruneMode; extern bool fPruneMode;
/** Number of bytes of block files that we're trying to stay below. */
extern uint64_t nPruneTarget; extern uint64_t nPruneTarget;
// Because validation code takes pointers to the map's CBlockIndex objects, if // Because validation code takes pointers to the map's CBlockIndex objects, if
@@ -176,6 +173,17 @@ public:
/** Store block on disk. If dbp is not nullptr, then it provides the known position of the block within a block file on disk. */ /** Store block on disk. If dbp is not nullptr, then it provides the known position of the block within a block file on disk. */
FlatFilePos SaveBlockToDisk(const CBlock& block, int nHeight, CChain& active_chain, const CChainParams& chainparams, const FlatFilePos* dbp); FlatFilePos SaveBlockToDisk(const CBlock& block, int nHeight, CChain& active_chain, const CChainParams& chainparams, const FlatFilePos* dbp);
/** Whether running in -prune mode. */
[[nodiscard]] bool IsPruneMode() const { return fPruneMode; }
/** Attempt to stay below this number of bytes of block files. */
[[nodiscard]] uint64_t GetPruneTarget() const { return nPruneTarget; }
[[nodiscard]] bool LoadingBlocks() const
{
return fImporting || fReindex;
}
/** Calculate the amount of disk space the block & undo files currently use */ /** Calculate the amount of disk space the block & undo files currently use */
uint64_t CalculateCurrentUsage(); uint64_t CalculateCurrentUsage();
+3 -3
View File
@@ -44,10 +44,10 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) { if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) {
LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex()); LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex());
} }
if (nPruneTarget == std::numeric_limits<uint64_t>::max()) { if (chainman.m_blockman.GetPruneTarget() == std::numeric_limits<uint64_t>::max()) {
LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n"); LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
} else if (nPruneTarget) { } else if (chainman.m_blockman.GetPruneTarget()) {
LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", nPruneTarget / 1024 / 1024); LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", chainman.m_blockman.GetPruneTarget() / 1024 / 1024);
} }
LOCK(cs_main); LOCK(cs_main);
+3 -2
View File
@@ -711,8 +711,9 @@ public:
LOCK(::cs_main); LOCK(::cs_main);
return chainman().m_blockman.m_have_pruned; return chainman().m_blockman.m_have_pruned;
} }
bool isReadyToBroadcast() override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload(); } bool isReadyToBroadcast() override { return !chainman().m_blockman.LoadingBlocks() && !isInitialBlockDownload(); }
bool isInitialBlockDownload() override { bool isInitialBlockDownload() override
{
return chainman().ActiveChainstate().IsInitialBlockDownload(); return chainman().ActiveChainstate().IsInitialBlockDownload();
} }
bool shutdownRequested() override { return ShutdownRequested(); } bool shutdownRequested() override { return ShutdownRequested(); }
+8 -7
View File
@@ -460,7 +460,7 @@ static RPCHelpMan getblockfrompeer()
// Fetching blocks before the node has syncing past their height can prevent block files from // Fetching blocks before the node has syncing past their height can prevent block files from
// being pruned, so we avoid it if the node is in prune mode. // being pruned, so we avoid it if the node is in prune mode.
if (node::fPruneMode && index->nHeight > WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip()->nHeight)) { if (chainman.m_blockman.IsPruneMode() && index->nHeight > WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip()->nHeight)) {
throw JSONRPCError(RPC_MISC_ERROR, "In prune mode, only blocks that the node has already synced previously can be fetched from a peer"); throw JSONRPCError(RPC_MISC_ERROR, "In prune mode, only blocks that the node has already synced previously can be fetched from a peer");
} }
@@ -775,10 +775,11 @@ static RPCHelpMan pruneblockchain()
}, },
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{ {
if (!node::fPruneMode)
throw JSONRPCError(RPC_MISC_ERROR, "Cannot prune blocks because node is not in prune mode.");
ChainstateManager& chainman = EnsureAnyChainman(request.context); ChainstateManager& chainman = EnsureAnyChainman(request.context);
if (!chainman.m_blockman.IsPruneMode()) {
throw JSONRPCError(RPC_MISC_ERROR, "Cannot prune blocks because node is not in prune mode.");
}
LOCK(cs_main); LOCK(cs_main);
Chainstate& active_chainstate = chainman.ActiveChainstate(); Chainstate& active_chainstate = chainman.ActiveChainstate();
CChain& active_chain = active_chainstate.m_chain; CChain& active_chain = active_chainstate.m_chain;
@@ -1266,15 +1267,15 @@ RPCHelpMan getblockchaininfo()
obj.pushKV("initialblockdownload", active_chainstate.IsInitialBlockDownload()); obj.pushKV("initialblockdownload", active_chainstate.IsInitialBlockDownload());
obj.pushKV("chainwork", tip.nChainWork.GetHex()); obj.pushKV("chainwork", tip.nChainWork.GetHex());
obj.pushKV("size_on_disk", chainman.m_blockman.CalculateCurrentUsage()); obj.pushKV("size_on_disk", chainman.m_blockman.CalculateCurrentUsage());
obj.pushKV("pruned", node::fPruneMode); obj.pushKV("pruned", chainman.m_blockman.IsPruneMode());
if (node::fPruneMode) { if (chainman.m_blockman.IsPruneMode()) {
obj.pushKV("pruneheight", chainman.m_blockman.GetFirstStoredBlock(tip)->nHeight); obj.pushKV("pruneheight", chainman.m_blockman.GetFirstStoredBlock(tip)->nHeight);
// if 0, execution bypasses the whole if block. // if 0, execution bypasses the whole if block.
bool automatic_pruning{args.GetIntArg("-prune", 0) != 1}; bool automatic_pruning{args.GetIntArg("-prune", 0) != 1};
obj.pushKV("automatic_pruning", automatic_pruning); obj.pushKV("automatic_pruning", automatic_pruning);
if (automatic_pruning) { if (automatic_pruning) {
obj.pushKV("prune_target_size", node::nPruneTarget); obj.pushKV("prune_target_size", chainman.m_blockman.GetPruneTarget());
} }
} }
+5 -4
View File
@@ -208,23 +208,24 @@ ChainTestingSetup::~ChainTestingSetup()
void TestingSetup::LoadVerifyActivateChainstate() void TestingSetup::LoadVerifyActivateChainstate()
{ {
auto& chainman{*Assert(m_node.chainman)};
node::ChainstateLoadOptions options; node::ChainstateLoadOptions options;
options.mempool = Assert(m_node.mempool.get()); options.mempool = Assert(m_node.mempool.get());
options.block_tree_db_in_memory = m_block_tree_db_in_memory; options.block_tree_db_in_memory = m_block_tree_db_in_memory;
options.coins_db_in_memory = m_coins_db_in_memory; options.coins_db_in_memory = m_coins_db_in_memory;
options.reindex = node::fReindex; options.reindex = node::fReindex;
options.reindex_chainstate = m_args.GetBoolArg("-reindex-chainstate", false); options.reindex_chainstate = m_args.GetBoolArg("-reindex-chainstate", false);
options.prune = node::fPruneMode; options.prune = chainman.m_blockman.IsPruneMode();
options.check_blocks = m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS); options.check_blocks = m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS);
options.check_level = m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL); options.check_level = m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL);
auto [status, error] = LoadChainstate(*Assert(m_node.chainman), m_cache_sizes, options); auto [status, error] = LoadChainstate(chainman, m_cache_sizes, options);
assert(status == node::ChainstateLoadStatus::SUCCESS); assert(status == node::ChainstateLoadStatus::SUCCESS);
std::tie(status, error) = VerifyLoadedChainstate(*Assert(m_node.chainman), options); std::tie(status, error) = VerifyLoadedChainstate(chainman, options);
assert(status == node::ChainstateLoadStatus::SUCCESS); assert(status == node::ChainstateLoadStatus::SUCCESS);
BlockValidationState state; BlockValidationState state;
if (!m_node.chainman->ActiveChainstate().ActivateBestChain(state)) { if (!chainman.ActiveChainstate().ActivateBestChain(state)) {
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString())); throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
} }
} }
+4 -5
View File
@@ -76,8 +76,6 @@ using node::BlockManager;
using node::BlockMap; using node::BlockMap;
using node::CBlockIndexHeightOnlyComparator; using node::CBlockIndexHeightOnlyComparator;
using node::CBlockIndexWorkComparator; using node::CBlockIndexWorkComparator;
using node::fImporting;
using node::fPruneMode;
using node::fReindex; using node::fReindex;
using node::ReadBlockFromDisk; using node::ReadBlockFromDisk;
using node::SnapshotMetadata; using node::SnapshotMetadata;
@@ -1573,8 +1571,9 @@ bool Chainstate::IsInitialBlockDownload() const
LOCK(cs_main); LOCK(cs_main);
if (m_cached_finished_ibd.load(std::memory_order_relaxed)) if (m_cached_finished_ibd.load(std::memory_order_relaxed))
return false; return false;
if (fImporting || fReindex) if (m_chainman.m_blockman.LoadingBlocks()) {
return true; return true;
}
if (m_chain.Tip() == nullptr) if (m_chain.Tip() == nullptr)
return true; return true;
if (m_chain.Tip()->nChainWork < m_chainman.MinimumChainWork()) { if (m_chain.Tip()->nChainWork < m_chainman.MinimumChainWork()) {
@@ -2411,7 +2410,7 @@ bool Chainstate::FlushStateToDisk(
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(); CoinsCacheSizeState cache_state = GetCoinsCacheSizeState();
LOCK(m_blockman.cs_LastBlockFile); LOCK(m_blockman.cs_LastBlockFile);
if (fPruneMode && (m_blockman.m_check_for_pruning || nManualPruneHeight > 0) && !fReindex) { if (m_blockman.IsPruneMode() && (m_blockman.m_check_for_pruning || nManualPruneHeight > 0) && !fReindex) {
// make sure we don't prune above any of the prune locks bestblocks // make sure we don't prune above any of the prune locks bestblocks
// pruning is height-based // pruning is height-based
int last_prune{m_chain.Height()}; // last height we can prune int last_prune{m_chain.Height()}; // last height we can prune
@@ -4097,7 +4096,7 @@ bool CVerifyDB::VerifyDB(
if (pindex->nHeight <= chainstate.m_chain.Height() - nCheckDepth) { if (pindex->nHeight <= chainstate.m_chain.Height() - nCheckDepth) {
break; break;
} }
if ((fPruneMode || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) { if ((chainstate.m_blockman.IsPruneMode() || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
// If pruning or running under an assumeutxo snapshot, only go // If pruning or running under an assumeutxo snapshot, only go
// back as far as we have data. // back as far as we have data.
LogPrintf("VerifyDB(): block verification stopping at height %d (pruning, no data)\n", pindex->nHeight); LogPrintf("VerifyDB(): block verification stopping at height %d (pruning, no data)\n", pindex->nHeight);