Skip to content

Commit 525c00f

Browse files
committed
versionbits: Expose VersionBitsConditionChecker via impl header
1 parent e74a704 commit 525c00f

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

src/versionbits.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -189,36 +189,6 @@ int AbstractThresholdConditionChecker::GetStateSinceHeightFor(const CBlockIndex*
189189
return pindexPrev->nHeight + 1;
190190
}
191191

192-
namespace
193-
{
194-
/**
195-
* Class to implement versionbits logic.
196-
*/
197-
class VersionBitsConditionChecker : public AbstractThresholdConditionChecker {
198-
private:
199-
const Consensus::BIP9Deployment& dep;
200-
201-
protected:
202-
int64_t BeginTime() const override { return dep.nStartTime; }
203-
int64_t EndTime() const override { return dep.nTimeout; }
204-
int MinActivationHeight() const override { return dep.min_activation_height; }
205-
int Period() const override { return dep.period; }
206-
int Threshold() const override { return dep.threshold; }
207-
208-
bool Condition(const CBlockIndex* pindex) const override
209-
{
210-
return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->nVersion & Mask()) != 0);
211-
}
212-
213-
public:
214-
explicit VersionBitsConditionChecker(const Consensus::BIP9Deployment& dep) : dep{dep} {}
215-
explicit VersionBitsConditionChecker(const Consensus::Params& params, Consensus::DeploymentPos id) : VersionBitsConditionChecker{params.vDeployments[id]} {}
216-
217-
uint32_t Mask() const { return (uint32_t{1}) << dep.bit; }
218-
};
219-
220-
} // namespace
221-
222192
BIP9Info VersionBitsCache::Info(const CBlockIndex& block_index, const Consensus::Params& params, Consensus::DeploymentPos id)
223193
{
224194
BIP9Info result;

src/versionbits_impl.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,30 @@ class AbstractThresholdConditionChecker {
4949
int GetStateSinceHeightFor(const CBlockIndex* pindexPrev, ThresholdConditionCache& cache) const;
5050
};
5151

52+
/**
53+
* Class to implement versionbits logic.
54+
*/
55+
class VersionBitsConditionChecker : public AbstractThresholdConditionChecker {
56+
private:
57+
const Consensus::BIP9Deployment& dep;
58+
59+
protected:
60+
int64_t BeginTime() const override { return dep.nStartTime; }
61+
int64_t EndTime() const override { return dep.nTimeout; }
62+
int MinActivationHeight() const override { return dep.min_activation_height; }
63+
int Period() const override { return dep.period; }
64+
int Threshold() const override { return dep.threshold; }
65+
66+
bool Condition(const CBlockIndex* pindex) const override
67+
{
68+
return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->nVersion & Mask()) != 0);
69+
}
70+
71+
public:
72+
explicit VersionBitsConditionChecker(const Consensus::BIP9Deployment& dep) : dep{dep} {}
73+
explicit VersionBitsConditionChecker(const Consensus::Params& params, Consensus::DeploymentPos id) : VersionBitsConditionChecker{params.vDeployments[id]} {}
74+
75+
uint32_t Mask() const { return (uint32_t{1}) << dep.bit; }
76+
};
77+
5278
#endif // BITCOIN_VERSIONBITS_IMPL_H

0 commit comments

Comments
 (0)