diff options
author | Anthony Towns <aj@erisian.com.au> | 2021-04-16 18:34:34 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2021-06-30 08:19:12 +1000 |
commit | c5f36725e877d8eb492383844f8ef7535466b366 (patch) | |
tree | ce68ede5ada96fed4a558a1f88e7354e4a1ac3b7 /src/versionbits.cpp | |
parent | 4a69b4dbe0d7f504811b67c399da7e6d11e4f805 (diff) |
[refactor] Move ComputeBlockVersion into VersionBitsCache
This also changes ComputeBlockVersion to take the versionbits cache
mutex once, rather than once for each versionbits deployment.
Diffstat (limited to 'src/versionbits.cpp')
-rw-r--r-- | src/versionbits.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/versionbits.cpp b/src/versionbits.cpp index 3497fc049e..94c3c9559f 100644 --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -212,16 +212,16 @@ uint32_t VersionBitsCache::Mask(const Consensus::Params& params, Consensus::Depl return VersionBitsConditionChecker(pos).Mask(params); } -extern VersionBitsCache g_versionbitscache; // removed in next commit - -int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params) +int32_t VersionBitsCache::ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params) { + LOCK(m_mutex); int32_t nVersion = VERSIONBITS_TOP_BITS; for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) { - ThresholdState state = g_versionbitscache.State(pindexPrev, params, static_cast<Consensus::DeploymentPos>(i)); + Consensus::DeploymentPos pos = static_cast<Consensus::DeploymentPos>(i); + ThresholdState state = VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, m_caches[pos]); if (state == ThresholdState::LOCKED_IN || state == ThresholdState::STARTED) { - nVersion |= g_versionbitscache.Mask(params, static_cast<Consensus::DeploymentPos>(i)); + nVersion |= Mask(params, pos); } } |