Skip to content

Commit 0c2eedd

Browse files
fanquakevijaydasmp
authored andcommitted
Merge 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@5526849) TheCharlatan: ACK 5526849 ryanofsky: Code review ACK 5526849 Tree-SHA512: 6869bd7aa4f0b59324e12eb8e3df47f2c9a3f3b0d9b7d45857426ec9e8b71c5573bdcf71db822f8c10aff7d8679a00a4bedc7a256c28f325e744e5d7267b41e9
1 parent db4fe78 commit 0c2eedd

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

src/validation.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,8 +2215,6 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
22152215
}
22162216
};
22172217

2218-
static std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> warningcache GUARDED_BY(cs_main);
2219-
22202218
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const ChainstateManager& chainman)
22212219
{
22222220
unsigned int flags = SCRIPT_VERIFY_NONE;
@@ -2997,7 +2995,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew)
29972995
const CBlockIndex* pindex = pindexNew;
29982996
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
29992997
WarningBitsConditionChecker checker(m_chainman, bit);
3000-
ThresholdState state = checker.GetStateFor(pindex, m_params.GetConsensus(), warningcache.at(bit));
2998+
ThresholdState state = checker.GetStateFor(pindex, m_params.GetConsensus(), m_chainman.m_warningcache.at(bit));
30012999
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
30023000
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
30033001
if (state == ThresholdState::ACTIVE) {
@@ -6102,11 +6100,6 @@ ChainstateManager::~ChainstateManager()
61026100
LOCK(::cs_main);
61036101

61046102
m_versionbitscache.Clear();
6105-
6106-
// TODO: The warning cache should probably become non-global
6107-
for (auto& i : warningcache) {
6108-
i.clear();
6109-
}
61106103
}
61116104

61126105
bool IsBIP30Repeat(const CBlockIndex& block_index)

src/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,8 @@ class ChainstateManager
918918
CBlockIndex** ppindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
919919
friend CChainState;
920920

921+
std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> m_warningcache GUARDED_BY(::cs_main);
922+
921923
public:
922924
explicit ChainstateManager(const CChainParams& chainparams) : m_chainparams{chainparams} { }
923925

0 commit comments

Comments
 (0)