Skip to content

Commit 6f5f37e

Browse files
committed
Merge bitcoin/bitcoin#27357: validation: Move warningcache to ChainstateManager and rename to m_warningcache
5526849 validation: Move warningcache to ChainstateManager (dimitaracev) Pull request description: Removes `warningcache` and moves it to `ChainstateManager`. Also removes the respective `TODO` completely. ACKs for top commit: ajtowns: ACK 5526849 dimitaracev: > ACK [5526849](bitcoin/bitcoin@5526849) TheCharlatan: ACK 5526849 ryanofsky: Code review ACK 5526849 Tree-SHA512: 6869bd7aa4f0b59324e12eb8e3df47f2c9a3f3b0d9b7d45857426ec9e8b71c5573bdcf71db822f8c10aff7d8679a00a4bedc7a256c28f325e744e5d7267b41e9
2 parents fbe48f9 + 5526849 commit 6f5f37e

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/validation.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,8 +1993,6 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
19931993
}
19941994
};
19951995

1996-
static std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> warningcache GUARDED_BY(cs_main);
1997-
19981996
static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const ChainstateManager& chainman)
19991997
{
20001998
const Consensus::Params& consensusparams = chainman.GetConsensus();
@@ -2640,7 +2638,7 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
26402638
const CBlockIndex* pindex = pindexNew;
26412639
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
26422640
WarningBitsConditionChecker checker(m_chainman, bit);
2643-
ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), warningcache.at(bit));
2641+
ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), m_chainman.m_warningcache.at(bit));
26442642
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
26452643
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
26462644
if (state == ThresholdState::ACTIVE) {
@@ -5586,11 +5584,6 @@ ChainstateManager::~ChainstateManager()
55865584
LOCK(::cs_main);
55875585

55885586
m_versionbitscache.Clear();
5589-
5590-
// TODO: The warning cache should probably become non-global
5591-
for (auto& i : warningcache) {
5592-
i.clear();
5593-
}
55945587
}
55955588

55965589
bool ChainstateManager::DetectSnapshotChainstate(CTxMemPool* mempool)

src/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ class ChainstateManager
938938
//! nullopt.
939939
std::optional<int> GetSnapshotBaseHeight() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
940940

941+
std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> m_warningcache GUARDED_BY(::cs_main);
942+
941943
//! Return true if a chainstate is considered usable.
942944
//!
943945
//! This is false when a background validation chainstate has completed its

0 commit comments

Comments
 (0)