diff options
author | Anthony Towns <aj@erisian.com.au> | 2022-04-15 06:53:19 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2022-05-10 12:09:33 +1000 |
commit | bb5c24b120a3ac7df367a1c5d9b075ca564efb5f (patch) | |
tree | fb615ac890a78c4536a985db148c0d70d4ad2ef7 /src/validation.cpp | |
parent | eca22c726ac48b4216bb68cc0f0bbd655c43ac12 (diff) | |
download | bitcoin-bb5c24b120a3ac7df367a1c5d9b075ca564efb5f.tar.xz |
validation: move g_versionbitscache into ChainstateManager
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 49be17d02c..63c0f9a4ac 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1907,10 +1907,11 @@ void StopScriptCheckWorkerThreads() class WarningBitsConditionChecker : public AbstractThresholdConditionChecker { private: - int bit; + const ChainstateManager& m_chainman; + int m_bit; public: - explicit WarningBitsConditionChecker(int bitIn) : bit(bitIn) {} + explicit WarningBitsConditionChecker(const ChainstateManager& chainman, int bit) : m_chainman{chainman}, m_bit(bit) {} int64_t BeginTime(const Consensus::Params& params) const override { return 0; } int64_t EndTime(const Consensus::Params& params) const override { return std::numeric_limits<int64_t>::max(); } @@ -1921,8 +1922,8 @@ public: { return pindex->nHeight >= params.MinBIP9WarningHeight && ((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && - ((pindex->nVersion >> bit) & 1) != 0 && - ((g_versionbitscache.ComputeBlockVersion(pindex->pprev, params) >> bit) & 1) == 0; + ((pindex->nVersion >> m_bit) & 1) != 0 && + ((m_chainman.m_versionbitscache.ComputeBlockVersion(pindex->pprev, params) >> m_bit) & 1) == 0; } }; @@ -2556,7 +2557,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew) if (!this->IsInitialBlockDownload()) { const CBlockIndex* pindex = pindexNew; for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) { - WarningBitsConditionChecker checker(bit); + WarningBitsConditionChecker checker(m_chainman, bit); ThresholdState state = checker.GetStateFor(pindex, m_params.GetConsensus(), warningcache.at(bit)); if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) { const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit); @@ -5216,9 +5217,9 @@ ChainstateManager::~ChainstateManager() { LOCK(::cs_main); - // TODO: The version bits cache and warning cache should probably become - // non-globals - g_versionbitscache.Clear(); + m_versionbitscache.Clear(); + + // TODO: The warning cache should probably become non-global for (auto& i : warningcache) { i.clear(); } |