Skip to content

Commit 4960589

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 e2272c2 commit 4960589

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
@@ -2226,8 +2226,6 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
22262226
}
22272227
};
22282228

2229-
static std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> warningcache GUARDED_BY(cs_main);
2230-
22312229
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const ChainstateManager& chainman)
22322230
{
22332231
unsigned int flags = SCRIPT_VERIFY_NONE;
@@ -3008,7 +3006,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew)
30083006
const CBlockIndex* pindex = pindexNew;
30093007
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
30103008
WarningBitsConditionChecker checker(m_chainman, bit);
3011-
ThresholdState state = checker.GetStateFor(pindex, m_params.GetConsensus(), warningcache.at(bit));
3009+
ThresholdState state = checker.GetStateFor(pindex, m_params.GetConsensus(), m_chainman.m_warningcache.at(bit));
30123010
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
30133011
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
30143012
if (state == ThresholdState::ACTIVE) {
@@ -6151,11 +6149,6 @@ ChainstateManager::~ChainstateManager()
61516149
LOCK(::cs_main);
61526150

61536151
m_versionbitscache.Clear();
6154-
6155-
// TODO: The warning cache should probably become non-global
6156-
for (auto& i : warningcache) {
6157-
i.clear();
6158-
}
61596152
}
61606153

61616154
bool IsBIP30Repeat(const CBlockIndex& block_index)

src/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,8 @@ class ChainstateManager
919919
const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
920920
friend CChainState;
921921

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

0 commit comments

Comments
 (0)