diff options
author | Anthony Towns <aj@erisian.com.au> | 2020-12-29 11:19:06 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2021-06-30 08:19:12 +1000 |
commit | 0cfd6c6a8f929d5567ac41f95c21548f115efee5 (patch) | |
tree | fd396692805022b432022c45da6bb2a18b2fa54b /src/versionbits.cpp | |
parent | 8ee3e0bed5bf2cd3c7a68ca6ba6c65f7b9a72cca (diff) |
[refactor] versionbits: make VersionBitsCache a full class
Moves the VersionBits* functions to be methods of the cache class,
and makes the cache and its lock private to the class.
Diffstat (limited to 'src/versionbits.cpp')
-rw-r--r-- | src/versionbits.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/versionbits.cpp b/src/versionbits.cpp index 07ecc93c93..0fbad0a64e 100644 --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -190,32 +190,32 @@ public: } // namespace -ThresholdState VersionBitsState(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos, VersionBitsCache& cache) +ThresholdState VersionBitsCache::State(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos) { - LOCK(cache.mutex); - return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.caches[pos]); + LOCK(m_mutex); + return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, m_caches[pos]); } -BIP9Stats VersionBitsStatistics(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos) +BIP9Stats VersionBitsCache::Statistics(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos) { return VersionBitsConditionChecker(pos).GetStateStatisticsFor(pindexPrev, params); } -int VersionBitsStateSinceHeight(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos, VersionBitsCache& cache) +int VersionBitsCache::StateSinceHeight(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos) { - LOCK(cache.mutex); - return VersionBitsConditionChecker(pos).GetStateSinceHeightFor(pindexPrev, params, cache.caches[pos]); + LOCK(m_mutex); + return VersionBitsConditionChecker(pos).GetStateSinceHeightFor(pindexPrev, params, m_caches[pos]); } -uint32_t VersionBitsMask(const Consensus::Params& params, Consensus::DeploymentPos pos) +uint32_t VersionBitsCache::Mask(const Consensus::Params& params, Consensus::DeploymentPos pos) { return VersionBitsConditionChecker(pos).Mask(params); } void VersionBitsCache::Clear() { - LOCK(mutex); + LOCK(m_mutex); for (unsigned int d = 0; d < Consensus::MAX_VERSION_BITS_DEPLOYMENTS; d++) { - caches[d].clear(); + m_caches[d].clear(); } } |