Changeset View
Changeset View
Standalone View
Standalone View
src/versionbits.cpp
Show First 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Class to implement versionbits logic. | * Class to implement versionbits logic. | ||||
*/ | */ | ||||
class VersionBitsConditionChecker : public AbstractThresholdConditionChecker { | class VersionBitsConditionChecker : public AbstractThresholdConditionChecker { | ||||
private: | private: | ||||
const Consensus::DeploymentPos id; | const Consensus::DeploymentPos id; | ||||
protected: | protected: | ||||
int64_t BeginTime(const Consensus::Params ¶ms) const { | int64_t BeginTime(const Consensus::Params ¶ms) const override { | ||||
return params.vDeployments[id].nStartTime; | return params.vDeployments[id].nStartTime; | ||||
} | } | ||||
int64_t EndTime(const Consensus::Params ¶ms) const { | int64_t EndTime(const Consensus::Params ¶ms) const override { | ||||
return params.vDeployments[id].nTimeout; | return params.vDeployments[id].nTimeout; | ||||
} | } | ||||
int Period(const Consensus::Params ¶ms) const { | int Period(const Consensus::Params ¶ms) const override { | ||||
return params.nMinerConfirmationWindow; | return params.nMinerConfirmationWindow; | ||||
} | } | ||||
int Threshold(const Consensus::Params ¶ms) const { | int Threshold(const Consensus::Params ¶ms) const override { | ||||
return params.nRuleChangeActivationThreshold; | return params.nRuleChangeActivationThreshold; | ||||
} | } | ||||
bool Condition(const CBlockIndex *pindex, | bool Condition(const CBlockIndex *pindex, | ||||
const Consensus::Params ¶ms) const { | const Consensus::Params ¶ms) const override { | ||||
return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == | return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == | ||||
VERSIONBITS_TOP_BITS) && | VERSIONBITS_TOP_BITS) && | ||||
(pindex->nVersion & Mask(params)) != 0); | (pindex->nVersion & Mask(params)) != 0); | ||||
} | } | ||||
public: | public: | ||||
VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {} | VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {} | ||||
uint32_t Mask(const Consensus::Params ¶ms) const { | uint32_t Mask(const Consensus::Params ¶ms) const { | ||||
Show All 31 Lines |