From 552684976b6df34ce563458f73812e6e494e3b0e Mon Sep 17 00:00:00 2001 From: dimitaracev Date: Tue, 28 Mar 2023 22:43:18 +0200 Subject: validation: Move warningcache to ChainstateManager --- src/validation.cpp | 9 +-------- src/validation.h | 2 ++ 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/validation.cpp b/src/validation.cpp index e82fead89e..c09c85662e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2005,8 +2005,6 @@ public: } }; -static std::array warningcache GUARDED_BY(cs_main); - static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const ChainstateManager& chainman) { const Consensus::Params& consensusparams = chainman.GetConsensus(); @@ -2662,7 +2660,7 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew) const CBlockIndex* pindex = pindexNew; for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) { WarningBitsConditionChecker checker(m_chainman, bit); - ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), warningcache.at(bit)); + ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), m_chainman.m_warningcache.at(bit)); if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) { const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit); if (state == ThresholdState::ACTIVE) { @@ -5593,11 +5591,6 @@ ChainstateManager::~ChainstateManager() LOCK(::cs_main); m_versionbitscache.Clear(); - - // TODO: The warning cache should probably become non-global - for (auto& i : warningcache) { - i.clear(); - } } bool ChainstateManager::DetectSnapshotChainstate(CTxMemPool* mempool) diff --git a/src/validation.h b/src/validation.h index aba863db09..cb66b94954 100644 --- a/src/validation.h +++ b/src/validation.h @@ -936,6 +936,8 @@ private: //! nullopt. std::optional GetSnapshotBaseHeight() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + std::array m_warningcache GUARDED_BY(::cs_main); + //! Return true if a chainstate is considered usable. //! //! This is false when a background validation chainstate has completed its -- cgit v1.2.3