|
|
@ -67,6 +67,13 @@ map<uint256, COrphanTx> mapOrphanTransactions; |
|
|
|
map<uint256, set<uint256> > mapOrphanTransactionsByPrev; |
|
|
|
map<uint256, set<uint256> > mapOrphanTransactionsByPrev; |
|
|
|
void EraseOrphansFor(NodeId peer); |
|
|
|
void EraseOrphansFor(NodeId peer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns true if there are nRequired or more blocks of minVersion or above |
|
|
|
|
|
|
|
* in the last Params().ToCheckBlockUpgradeMajority() blocks, starting at pstart |
|
|
|
|
|
|
|
* and going backwards. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned int nRequired); |
|
|
|
|
|
|
|
|
|
|
|
/** Constant stuff for coinbase transactions we create: */ |
|
|
|
/** Constant stuff for coinbase transactions we create: */ |
|
|
|
CScript COINBASE_FLAGS; |
|
|
|
CScript COINBASE_FLAGS; |
|
|
|
|
|
|
|
|
|
|
@ -2479,8 +2486,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta |
|
|
|
return state.DoS(100, error("%s : forked chain older than last checkpoint (height %d)", __func__, nHeight)); |
|
|
|
return state.DoS(100, error("%s : forked chain older than last checkpoint (height %d)", __func__, nHeight)); |
|
|
|
|
|
|
|
|
|
|
|
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
|
|
|
|
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
|
|
|
|
if (block.nVersion < 2 && |
|
|
|
if (block.nVersion < 2 && IsSuperMajority(2, pindexPrev, Params().RejectBlockOutdatedMajority())) |
|
|
|
CBlockIndex::IsSuperMajority(2, pindexPrev, Params().RejectBlockOutdatedMajority())) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return state.Invalid(error("%s : rejected nVersion=1 block", __func__), |
|
|
|
return state.Invalid(error("%s : rejected nVersion=1 block", __func__), |
|
|
|
REJECT_OBSOLETE, "bad-version"); |
|
|
|
REJECT_OBSOLETE, "bad-version"); |
|
|
@ -2501,8 +2507,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn |
|
|
|
|
|
|
|
|
|
|
|
// Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
|
|
|
|
// Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
|
|
|
|
// if 750 of the last 1,000 blocks are version 2 or greater (51/100 if testnet):
|
|
|
|
// if 750 of the last 1,000 blocks are version 2 or greater (51/100 if testnet):
|
|
|
|
if (block.nVersion >= 2 && |
|
|
|
if (block.nVersion >= 2 && IsSuperMajority(2, pindexPrev, Params().EnforceBlockUpgradeMajority())) |
|
|
|
CBlockIndex::IsSuperMajority(2, pindexPrev, Params().EnforceBlockUpgradeMajority())) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
CScript expect = CScript() << nHeight; |
|
|
|
CScript expect = CScript() << nHeight; |
|
|
|
if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || |
|
|
|
if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || |
|
|
@ -2600,7 +2605,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex, |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CBlockIndex::IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned int nRequired) |
|
|
|
static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned int nRequired) |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned int nToCheck = Params().ToCheckBlockUpgradeMajority(); |
|
|
|
unsigned int nToCheck = Params().ToCheckBlockUpgradeMajority(); |
|
|
|
unsigned int nFound = 0; |
|
|
|
unsigned int nFound = 0; |
|
|
|