aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitaracev <dimitaracev@protonmail.com>2023-03-28 22:43:18 +0200
committerdimitaracev <dimitaracev@protonmail.com>2023-03-29 13:40:42 +0200
commit552684976b6df34ce563458f73812e6e494e3b0e (patch)
tree98138d52f0032d4b2795c39bcae6a29b20b83962 /src
parent68828288e5d35c17848ab3da8cd231d1b69651c0 (diff)
downloadbitcoin-552684976b6df34ce563458f73812e6e494e3b0e.tar.xz
validation: Move warningcache to ChainstateManager
Diffstat (limited to 'src')
-rw-r--r--src/validation.cpp9
-rw-r--r--src/validation.h2
2 files changed, 3 insertions, 8 deletions
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<ThresholdConditionCache, VERSIONBITS_NUM_BITS> 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<int> GetSnapshotBaseHeight() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
+ std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> 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