mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
validation: Move warningcache to ChainstateManager
This commit is contained in:
parent
68828288e5
commit
552684976b
2 changed files with 3 additions and 8 deletions
|
@ -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)
|
static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const ChainstateManager& chainman)
|
||||||
{
|
{
|
||||||
const Consensus::Params& consensusparams = chainman.GetConsensus();
|
const Consensus::Params& consensusparams = chainman.GetConsensus();
|
||||||
|
@ -2662,7 +2660,7 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
|
||||||
const CBlockIndex* pindex = pindexNew;
|
const CBlockIndex* pindex = pindexNew;
|
||||||
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
|
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
|
||||||
WarningBitsConditionChecker checker(m_chainman, 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) {
|
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
|
||||||
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
|
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
|
||||||
if (state == ThresholdState::ACTIVE) {
|
if (state == ThresholdState::ACTIVE) {
|
||||||
|
@ -5593,11 +5591,6 @@ ChainstateManager::~ChainstateManager()
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
|
|
||||||
m_versionbitscache.Clear();
|
m_versionbitscache.Clear();
|
||||||
|
|
||||||
// TODO: The warning cache should probably become non-global
|
|
||||||
for (auto& i : warningcache) {
|
|
||||||
i.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChainstateManager::DetectSnapshotChainstate(CTxMemPool* mempool)
|
bool ChainstateManager::DetectSnapshotChainstate(CTxMemPool* mempool)
|
||||||
|
|
|
@ -936,6 +936,8 @@ private:
|
||||||
//! nullopt.
|
//! nullopt.
|
||||||
std::optional<int> GetSnapshotBaseHeight() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
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.
|
//! Return true if a chainstate is considered usable.
|
||||||
//!
|
//!
|
||||||
//! This is false when a background validation chainstate has completed its
|
//! This is false when a background validation chainstate has completed its
|
||||||
|
|
Loading…
Add table
Reference in a new issue