From 53a2dd6c911eb36c45a8ce0ddcf494de4b31709b Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Sun, 17 Dec 2023 18:44:58 +1000 Subject: [PATCH] versionbits: Expose VersionBitsConditionChecker via impl header --- src/versionbits.cpp | 31 ------------------------------- src/versionbits_impl.h | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/versionbits.cpp b/src/versionbits.cpp index 7192bf1d4c4be..0ed38895c7f0b 100644 --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -187,36 +187,6 @@ int AbstractThresholdConditionChecker::GetStateSinceHeightFor(const CBlockIndex* return pindexPrev->nHeight + 1; } -namespace -{ -/** - * Class to implement versionbits logic. - */ -class VersionBitsConditionChecker : public AbstractThresholdConditionChecker { -private: - const Consensus::BIP9Deployment& dep; - -protected: - int64_t BeginTime() const override { return dep.nStartTime; } - int64_t EndTime() const override { return dep.nTimeout; } - int MinActivationHeight() const override { return dep.min_activation_height; } - int Period() const override { return dep.period; } - int Threshold() const override { return dep.threshold; } - - bool Condition(const CBlockIndex* pindex) const override - { - return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->nVersion & Mask()) != 0); - } - -public: - explicit VersionBitsConditionChecker(const Consensus::BIP9Deployment& dep) : dep{dep} {} - explicit VersionBitsConditionChecker(const Consensus::Params& params, Consensus::DeploymentPos id) : VersionBitsConditionChecker{params.vDeployments[id]} {} - - uint32_t Mask() const { return (uint32_t{1}) << dep.bit; } -}; - -} // namespace - BIP9Info VersionBitsCache::Info(const CBlockIndex& block_index, const Consensus::Params& params, Consensus::DeploymentPos id) { BIP9Info result; @@ -253,7 +223,6 @@ BIP9Info VersionBitsCache::Info(const CBlockIndex& block_index, const Consensus: return result; } - BIP9GBTStatus VersionBitsCache::GBTStatus(const CBlockIndex& block_index, const Consensus::Params& params) { BIP9GBTStatus result; diff --git a/src/versionbits_impl.h b/src/versionbits_impl.h index 16c03ff11437c..92aa8d7c936bd 100644 --- a/src/versionbits_impl.h +++ b/src/versionbits_impl.h @@ -52,4 +52,30 @@ class AbstractThresholdConditionChecker { int GetStateSinceHeightFor(const CBlockIndex* pindexPrev, ThresholdConditionCache& cache) const; }; +/** + * Class to implement versionbits logic. + */ +class VersionBitsConditionChecker : public AbstractThresholdConditionChecker { +private: + const Consensus::BIP9Deployment& dep; + +protected: + int64_t BeginTime() const override { return dep.nStartTime; } + int64_t EndTime() const override { return dep.nTimeout; } + int MinActivationHeight() const override { return dep.min_activation_height; } + int Period() const override { return dep.period; } + int Threshold() const override { return dep.threshold; } + + bool Condition(const CBlockIndex* pindex) const override + { + return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->nVersion & Mask()) != 0); + } + +public: + explicit VersionBitsConditionChecker(const Consensus::BIP9Deployment& dep) : dep{dep} {} + explicit VersionBitsConditionChecker(const Consensus::Params& params, Consensus::DeploymentPos id) : VersionBitsConditionChecker{params.vDeployments[id]} {} + + uint32_t Mask() const { return (uint32_t{1}) << dep.bit; } +}; + #endif // BITCOIN_VERSIONBITS_IMPL_H