mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
[refactor] Add versionbits deployments to deploymentstatus.h
Adds support for versionbits deployments to DeploymentEnabled, DeploymentActiveAfter and DeploymentActiveAt. Also moves versionbitscache from validation to deploymentstatus.
This commit is contained in:
@@ -6,9 +6,13 @@
|
||||
#define BITCOIN_DEPLOYMENTSTATUS_H
|
||||
|
||||
#include <chain.h>
|
||||
#include <versionbits.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
/** Global cache for versionbits deployment status */
|
||||
extern VersionBitsCache versionbitscache;
|
||||
|
||||
/** Determine if a deployment is active for the next block */
|
||||
inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::BuriedDeployment dep)
|
||||
{
|
||||
@@ -16,6 +20,12 @@ inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus
|
||||
return (pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1) >= params.DeploymentHeight(dep);
|
||||
}
|
||||
|
||||
inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos dep)
|
||||
{
|
||||
assert(Consensus::ValidDeployment(dep));
|
||||
return ThresholdState::ACTIVE == VersionBitsState(pindexPrev, params, dep, versionbitscache);
|
||||
}
|
||||
|
||||
/** Determine if a deployment is active for this block */
|
||||
inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::BuriedDeployment dep)
|
||||
{
|
||||
@@ -23,6 +33,12 @@ inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params
|
||||
return index.nHeight >= params.DeploymentHeight(dep);
|
||||
}
|
||||
|
||||
inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::DeploymentPos dep)
|
||||
{
|
||||
assert(Consensus::ValidDeployment(dep));
|
||||
return DeploymentActiveAfter(index.pprev, params, dep);
|
||||
}
|
||||
|
||||
/** Determine if a deployment is enabled (can ever be active) */
|
||||
inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::BuriedDeployment dep)
|
||||
{
|
||||
@@ -30,4 +46,10 @@ inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::Buried
|
||||
return params.DeploymentHeight(dep) != std::numeric_limits<int>::max();
|
||||
}
|
||||
|
||||
inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::DeploymentPos dep)
|
||||
{
|
||||
assert(Consensus::ValidDeployment(dep));
|
||||
return params.vDeployments[dep].nTimeout != 0;
|
||||
}
|
||||
|
||||
#endif // BITCOIN_DEPLOYMENTSTATUS_H
|
||||
|
||||
Reference in New Issue
Block a user