Skip to content

Commit 5526849

Browse files
committed
validation: Move warningcache to ChainstateManager
1 parent 6882828 commit 5526849

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
@@ -2005,8 +2005,6 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
20052005
}
20062006
};
20072007

2008-
static std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> warningcache GUARDED_BY(cs_main);
2009-
20102008
static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const ChainstateManager& chainman)
20112009
{
20122010
const Consensus::Params& consensusparams = chainman.GetConsensus();
@@ -2662,7 +2660,7 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
26622660
const CBlockIndex* pindex = pindexNew;
26632661
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
26642662
WarningBitsConditionChecker checker(m_chainman, bit);
2665-
ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), warningcache.at(bit));
2663+
ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), m_chainman.m_warningcache.at(bit));
26662664
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
26672665
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
26682666
if (state == ThresholdState::ACTIVE) {
@@ -5593,11 +5591,6 @@ ChainstateManager::~ChainstateManager()
55935591
LOCK(::cs_main);
55945592

55955593
m_versionbitscache.Clear();
5596-
5597-
// TODO: The warning cache should probably become non-global
5598-
for (auto& i : warningcache) {
5599-
i.clear();
5600-
}
56015594
}
56025595

56035596
bool ChainstateManager::DetectSnapshotChainstate(CTxMemPool* mempool)

src/validation.h

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

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

0 commit comments

Comments
 (0)