/// <summary> /// Computes what the block version of a newly created block should be, given a previous header and the /// current set of BIP9 deployments defined in the consensus. /// </summary> /// <param name="prevChainedHeader">The header of the previous block in the chain.</param> /// <remarks>This method is currently used during block creation only. Different nodes may not implement /// BIP9, or may disagree about what the current valid set of deployments are. It is therefore not strictly /// possible to validate a block version number in anything more than general terms.</remarks> public int ComputeBlockVersion(ChainedHeader prevChainedHeader) { uint version = ThresholdConditionCache.VersionbitsTopBits; var thresholdConditionCache = new ThresholdConditionCache(this.Parent.Network.Consensus); for (int deployment = 0; deployment < thresholdConditionCache.ArraySize; deployment++) { ThresholdState state = thresholdConditionCache.GetState(prevChainedHeader, deployment); if ((state == ThresholdState.LockedIn) || (state == ThresholdState.Started)) { version |= thresholdConditionCache.Mask(deployment); } } return((int)version); }
private int ComputeBlockVersion(ChainedHeader prevChainedHeader, NBitcoin.Consensus consensus) { uint version = ThresholdConditionCache.VersionbitsTopBits; var thresholdConditionCache = new ThresholdConditionCache(consensus); IEnumerable <BIP9Deployments> deployments = Enum.GetValues(typeof(BIP9Deployments)).OfType <BIP9Deployments>(); foreach (BIP9Deployments deployment in deployments) { ThresholdState state = thresholdConditionCache.GetState(prevChainedHeader, deployment); if ((state == ThresholdState.LockedIn) || (state == ThresholdState.Started)) { version |= thresholdConditionCache.Mask(deployment); } } return((int)version); }
private int ComputeBlockVersion(ChainedBlock pindexPrev, NBitcoin.Consensus consensus) { var nVersion = ThresholdConditionCache.VERSIONBITS_TOP_BITS; var thresholdConditionCache = new ThresholdConditionCache(consensus); var deploymensts = Enum.GetValues(typeof(BIP9Deployments)) .OfType <BIP9Deployments>(); foreach (var deployment in deploymensts) { var state = thresholdConditionCache.GetState(pindexPrev, deployment); if (state == ThresholdState.LockedIn || state == ThresholdState.Started) { nVersion |= thresholdConditionCache.Mask(deployment); } } return((int)nVersion); }
private int ComputeBlockVersion(ChainedBlock prevChainedBlock, NBitcoin.Consensus consensus) { uint nVersion = ThresholdConditionCache.VERSIONBITS_TOP_BITS; var thresholdConditionCache = new ThresholdConditionCache(consensus); IEnumerable <BIP9Deployments> deploymensts = Enum.GetValues(typeof(BIP9Deployments)) .OfType <BIP9Deployments>(); foreach (BIP9Deployments deployment in deploymensts) { ThresholdState state = thresholdConditionCache.GetState(prevChainedBlock, deployment); if ((state == ThresholdState.LockedIn) || (state == ThresholdState.Started)) { nVersion |= thresholdConditionCache.Mask(deployment); } } return((int)nVersion); }