aboutsummaryrefslogtreecommitdiff
path: root/src/versionbits.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-04-16 18:33:02 +1000
committerAnthony Towns <aj@erisian.com.au>2021-06-30 08:19:12 +1000
commit4a69b4dbe0d7f504811b67c399da7e6d11e4f805 (patch)
treef68a96ce61f4cbc31c2550f75950c450e18fb98f /src/versionbits.cpp
parent0cfd6c6a8f929d5567ac41f95c21548f115efee5 (diff)
downloadbitcoin-4a69b4dbe0d7f504811b67c399da7e6d11e4f805.tar.xz
[move-only] Move ComputeBlockVersion from validation to versionbits
Diffstat (limited to 'src/versionbits.cpp')
-rw-r--r--src/versionbits.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/versionbits.cpp b/src/versionbits.cpp
index 0fbad0a64e..3497fc049e 100644
--- a/src/versionbits.cpp
+++ b/src/versionbits.cpp
@@ -212,6 +212,22 @@ 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 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));
+ if (state == ThresholdState::LOCKED_IN || state == ThresholdState::STARTED) {
+ nVersion |= g_versionbitscache.Mask(params, static_cast<Consensus::DeploymentPos>(i));
+ }
+ }
+
+ return nVersion;
+}
+
void VersionBitsCache::Clear()
{
LOCK(m_mutex);