mirror of
https://github.com/bitcoin/bips.git
synced 2025-05-12 12:03:29 +00:00
Merge pull request #512 from da2ce7/bip148
Stop UASF enforcement if SegWit has IsLockedIn state.
This commit is contained in:
commit
1f6888e96d
@ -30,21 +30,30 @@ It is hoped that miners will respond to this BIP by activating segwit early, bef
|
|||||||
|
|
||||||
All times are specified according to median past time.
|
All times are specified according to median past time.
|
||||||
|
|
||||||
This BIP will be activate between midnight August 1st 2017 (epoch time 1501545600) and midnight November 15th 2017 (epoch time 1510704000) if the existing segwit deployment is not activated before epoch time 1501545600. This BIP will cease to be active when the existing segwit deployment activates.
|
This BIP will be active between midnight August 1st 2017 (epoch time 1501545600) and midnight November 15th 2017 (epoch time 1510704000) if the existing segwit deployment is not locked-in or activated before epoch time 1501545600. This BIP will cease to be active when segwit is locked-in.
|
||||||
|
|
||||||
While this BIP is active, all blocks must set the nVersion header top 3 bits to 001 together with bit field (1<<1) (according to the existing segwit deployment). Blocks that do not signal as required will be rejected.
|
While this BIP is active, all blocks must set the nVersion header top 3 bits to 001 together with bit field (1<<1) (according to the existing segwit deployment). Blocks that do not signal as required will be rejected.
|
||||||
|
|
||||||
=== Reference implementation ===
|
=== Reference implementation ===
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
// BIP148 mandatory segwit signalling.
|
// Check if Segregated Witness is Locked In
|
||||||
if (pindex->GetMedianTimePast() >= 1501545600 && // Tue 1 Aug 2017 00:00:00 UTC
|
bool IsWitnessLockedIn(const CBlockIndex* pindexPrev, const Consensus::Params& params)
|
||||||
pindex->GetMedianTimePast() <= 1510704000 && // Wed 15 Nov 2017 00:00:00 UTC
|
|
||||||
!IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus()))
|
|
||||||
{
|
{
|
||||||
// versionbits topbit and segwit flag must be set.
|
LOCK(cs_main);
|
||||||
if ((pindex->nVersion & VERSIONBITS_TOP_MASK) != VERSIONBITS_TOP_BITS ||
|
return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == THRESHOLD_LOCKED_IN);
|
||||||
(pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) == 0) {
|
}
|
||||||
|
|
||||||
|
// BIP148 mandatory segwit signalling.
|
||||||
|
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
|
||||||
|
(!IsWitnessLockedIn(pindex->pprev, chainparams.GetConsensus()) && // Segwit is not locked in
|
||||||
|
!IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus())) ) // and is not active.
|
||||||
|
{
|
||||||
|
bool fVersionBits = (pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS;
|
||||||
|
bool fSegbit = (pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) != 0;
|
||||||
|
if (!(fVersionBits && fSegbit)) {
|
||||||
return state.DoS(0, error("ConnectBlock(): relayed block must signal for segwit, please upgrade"), REJECT_INVALID, "bad-no-segwit");
|
return state.DoS(0, error("ConnectBlock(): relayed block must signal for segwit, please upgrade"), REJECT_INVALID, "bad-no-segwit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user