MCPcopy Create free account
hub / github.com/ElementsProject/elements / ComputeBlockVersion

Method ComputeBlockVersion

src/versionbits.cpp:247–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247int32_t VersionBitsCache::ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params)
248{
249 LOCK(m_mutex);
250 int32_t nVersion = VERSIONBITS_TOP_BITS;
251
252 for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) {
253 Consensus::DeploymentPos pos = static_cast<Consensus::DeploymentPos>(i);
254 ThresholdState state = VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, m_caches[pos]);
255 if (state == ThresholdState::LOCKED_IN || state == ThresholdState::STARTED) {
256 nVersion |= Mask(params, pos);
257 }
258 }
259
260 if (!gArgs.GetBoolArg("-con_dyna_deploy_signal", true)) {
261 auto dynafed = Consensus::DeploymentPos::DEPLOYMENT_DYNA_FED;
262 int bit = params.vDeployments[dynafed].bit;
263 if (bit > 0 && bit < VERSIONBITS_NUM_BITS) {
264 nVersion &= ~Mask(params, dynafed);
265 }
266 }
267
268 return nVersion;
269}
270
271void VersionBitsCache::Clear()
272{

Callers 3

ConditionMethod · 0.80
CreateNewBlockMethod · 0.80

Calls 4

GetBoolArgMethod · 0.80
MaskFunction · 0.50
GetStateForMethod · 0.45

Tested by 1