diff options
author | Cameron Garnham <da2ce7@gmail.com> | 2017-04-04 11:38:38 +0200 |
---|---|---|
committer | Cameron Garnham <da2ce7@gmail.com> | 2017-04-04 12:46:20 +0200 |
commit | 2a97af80db8e82d77e1d40968f39774319e23868 (patch) | |
tree | c56da42a3079c31c6487cb4cb638e0709dfd0723 /bip-0148.mediawiki | |
parent | b7850ab9171874e417d5f0e0e4e0727edf4211fb (diff) |
Refactor Code-Example with Better Formatting
No-need to calculate the GetMedianTimePast() value twice.
Diffstat (limited to 'bip-0148.mediawiki')
-rw-r--r-- | bip-0148.mediawiki | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/bip-0148.mediawiki b/bip-0148.mediawiki index 13ad4cd..5accfcf 100644 --- a/bip-0148.mediawiki +++ b/bip-0148.mediawiki @@ -38,13 +38,14 @@ While this BIP is active, all blocks must set the nVersion header top 3 bits to <pre> // BIP148 mandatory segwit signalling. -if (pindex->GetMedianTimePast() >= 1501545600 && // Tue 1 Aug 2017 00:00:00 UTC - pindex->GetMedianTimePast() <= 1510704000 && // Wed 15 Nov 2017 00:00:00 UTC - !IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus())) +int64_t nMedianTimePast = pindex->GetMedianTimePast(); +if ( (nMedianTimePast >= 1501545600) && // Tue 01 Aug 2017 00:00:00 UTC + (nMedianTimePast <= 1510704000) && // Wed 15 Nov 2017 00:00:00 UTC + (!IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus())) ) // Segwit is not active { - // versionbits topbit and segwit flag must be set. - if ((pindex->nVersion & VERSIONBITS_TOP_MASK) != VERSIONBITS_TOP_BITS || - (pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) == 0) { + bool fVersionBits = (pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS; // BIP9 bit set + bool fSegbit = (pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) != 0; // segwit bit set + if (!(fVersionBits && fSegbit)) { return state.DoS(0, error("ConnectBlock(): relayed block must signal for segwit, please upgrade"), REJECT_INVALID, "bad-no-segwit"); } } |