Skip to content

Commit 4a69b4d

Browse files
committed
[move-only] Move ComputeBlockVersion from validation to versionbits
1 parent 0cfd6c6 commit 4a69b4d

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

src/validation.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,20 +1606,6 @@ void StopScriptCheckWorkerThreads()
16061606
scriptcheckqueue.StopWorkerThreads();
16071607
}
16081608

1609-
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params)
1610-
{
1611-
int32_t nVersion = VERSIONBITS_TOP_BITS;
1612-
1613-
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) {
1614-
ThresholdState state = g_versionbitscache.State(pindexPrev, params, static_cast<Consensus::DeploymentPos>(i));
1615-
if (state == ThresholdState::LOCKED_IN || state == ThresholdState::STARTED) {
1616-
nVersion |= g_versionbitscache.Mask(params, static_cast<Consensus::DeploymentPos>(i));
1617-
}
1618-
}
1619-
1620-
return nVersion;
1621-
}
1622-
16231609
/**
16241610
* Threshold condition checker that triggers when unknown versionbits are seen on the network.
16251611
*/

src/validation.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,11 +1019,6 @@ class ChainstateManager
10191019
/** Global variable that points to the active block tree (protected by cs_main) */
10201020
extern std::unique_ptr<CBlockTreeDB> pblocktree;
10211021

1022-
/**
1023-
* Determine what nVersion a new block should use.
1024-
*/
1025-
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params);
1026-
10271022
using FopenFn = std::function<FILE*(const fs::path&, const char*)>;
10281023

10291024
/** Dump the mempool to disk. */

src/versionbits.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,22 @@ uint32_t VersionBitsCache::Mask(const Consensus::Params& params, Consensus::Depl
212212
return VersionBitsConditionChecker(pos).Mask(params);
213213
}
214214

215+
extern VersionBitsCache g_versionbitscache; // removed in next commit
216+
217+
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params)
218+
{
219+
int32_t nVersion = VERSIONBITS_TOP_BITS;
220+
221+
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) {
222+
ThresholdState state = g_versionbitscache.State(pindexPrev, params, static_cast<Consensus::DeploymentPos>(i));
223+
if (state == ThresholdState::LOCKED_IN || state == ThresholdState::STARTED) {
224+
nVersion |= g_versionbitscache.Mask(params, static_cast<Consensus::DeploymentPos>(i));
225+
}
226+
}
227+
228+
return nVersion;
229+
}
230+
215231
void VersionBitsCache::Clear()
216232
{
217233
LOCK(m_mutex);

src/versionbits.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,9 @@ class VersionBitsCache
9696
void Clear();
9797
};
9898

99+
/**
100+
* Determine what nVersion a new block should use.
101+
*/
102+
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params);
103+
99104
#endif // BITCOIN_VERSIONBITS_H

0 commit comments

Comments
 (0)