mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-08 19:01:08 +02:00
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
53 lines
2.2 KiB
C++
53 lines
2.2 KiB
C++
// Copyright (c) 2020-2022 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_DEPLOYMENTSTATUS_H
|
|
#define BITCOIN_DEPLOYMENTSTATUS_H
|
|
|
|
#include <chain.h>
|
|
#include <versionbits.h>
|
|
|
|
#include <limits>
|
|
|
|
/** Determine if a deployment is active for the next block */
|
|
inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache& versionbitscache)
|
|
{
|
|
assert(Consensus::ValidDeployment(dep));
|
|
return (pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1) >= params.DeploymentHeight(dep);
|
|
}
|
|
|
|
inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
|
|
{
|
|
assert(Consensus::ValidDeployment(dep));
|
|
return ThresholdState::ACTIVE == versionbitscache.State(pindexPrev, params, dep);
|
|
}
|
|
|
|
/** Determine if a deployment is active for this block */
|
|
inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache& versionbitscache)
|
|
{
|
|
assert(Consensus::ValidDeployment(dep));
|
|
return index.nHeight >= params.DeploymentHeight(dep);
|
|
}
|
|
|
|
inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
|
|
{
|
|
assert(Consensus::ValidDeployment(dep));
|
|
return DeploymentActiveAfter(index.pprev, params, dep, versionbitscache);
|
|
}
|
|
|
|
/** Determine if a deployment is enabled (can ever be active) */
|
|
inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::BuriedDeployment dep)
|
|
{
|
|
assert(Consensus::ValidDeployment(dep));
|
|
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].nStartTime != Consensus::BIP9Deployment::NEVER_ACTIVE;
|
|
}
|
|
|
|
#endif // BITCOIN_DEPLOYMENTSTATUS_H
|