[move-only] Move ComputeBlockVersion from validation to versionbits
This commit is contained in:
1 parent
0cfd6c6a8f
commit
4a69b4dbe0
4 files changed
+21
-19
No files matched your search
@@ -1606,20 +1606,6 @@ void StopScriptCheckWorkerThreads()
|
|||||||
scriptcheckqueue.StopWorkerThreads();
|
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.
|
* Threshold condition checker that triggers when unknown versionbits are seen on the network.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1019,11 +1019,6 @@ public:
|
|||||||
/** Global variable that points to the active block tree (protected by cs_main) */
|
/** Global variable that points to the active block tree (protected by cs_main) */
|
||||||
extern std::unique_ptr<CBlockTreeDB> pblocktree;
|
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*)>;
|
using FopenFn = std::function<FILE*(const fs::path&, const char*)>;
|
||||||
|
|
||||||
/** Dump the mempool to disk. */
|
/** Dump the mempool to disk. */
|
||||||
|
|||||||
@@ -212,6 +212,22 @@ uint32_t VersionBitsCache::Mask(const Consensus::Params& params, Consensus::Depl
|
|||||||
return VersionBitsConditionChecker(pos).Mask(params);
|
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()
|
void VersionBitsCache::Clear()
|
||||||
{
|
{
|
||||||
LOCK(m_mutex);
|
LOCK(m_mutex);
|
||||||
|
|||||||
@@ -96,4 +96,9 @@ public:
|
|||||||
void Clear();
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine what nVersion a new block should use.
|
||||||
|
*/
|
||||||
|
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params);
|
||||||
|
|
||||||
#endif // BITCOIN_VERSIONBITS_H
|
#endif // BITCOIN_VERSIONBITS_H
|
||||||
Reference in new issue
Block a user