diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/validation.cpp | 14 | ||||
-rw-r--r-- | src/validation.h | 5 | ||||
-rw-r--r-- | src/versionbits.cpp | 16 | ||||
-rw-r--r-- | src/versionbits.h | 5 |
4 files changed, 21 insertions, 19 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 024f643be5..ee10e047bd 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1606,20 +1606,6 @@ void StopScriptCheckWorkerThreads() scriptcheckqueue.StopWorkerThreads(); } -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; -} - /** * Threshold condition checker that triggers when unknown versionbits are seen on the network. */ diff --git a/src/validation.h b/src/validation.h index 0f00556053..3d66e3161d 100644 --- a/src/validation.h +++ b/src/validation.h @@ -1019,11 +1019,6 @@ public: /** Global variable that points to the active block tree (protected by cs_main) */ extern std::unique_ptr<CBlockTreeDB> pblocktree; -/** - * Determine what nVersion a new block should use. - */ -int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params); - using FopenFn = std::function<FILE*(const fs::path&, const char*)>; /** Dump the mempool to disk. */ 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); diff --git a/src/versionbits.h b/src/versionbits.h index 4ede920803..c18a8d1176 100644 --- a/src/versionbits.h +++ b/src/versionbits.h @@ -96,4 +96,9 @@ public: void Clear(); }; +/** + * Determine what nVersion a new block should use. + */ +int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params); + #endif // BITCOIN_VERSIONBITS_H |