Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 593 Lines • ▼ Show 20 Lines | |||||
bool IsDAAEnabled(const Config &config, const CBlockIndex *pindexPrev) { | bool IsDAAEnabled(const Config &config, const CBlockIndex *pindexPrev) { | ||||
if (pindexPrev == nullptr) { | if (pindexPrev == nullptr) { | ||||
return false; | return false; | ||||
} | } | ||||
return IsDAAEnabled(config, pindexPrev->nHeight); | return IsDAAEnabled(config, pindexPrev->nHeight); | ||||
} | } | ||||
static bool IsMonolithEnabled(const Config &config, int64_t nMedianTimePast) { | |||||
return nMedianTimePast >= | |||||
config.GetChainParams().GetConsensus().monolithActivationTime; | |||||
} | |||||
bool IsMonolithEnabled(const Config &config, const CBlockIndex *pindexPrev) { | |||||
if (pindexPrev == nullptr) { | |||||
return false; | |||||
} | |||||
return IsMonolithEnabled(config, pindexPrev->GetMedianTimePast()); | |||||
} | |||||
/** | /** | ||||
* Make mempool consistent after a reorg, by re-adding or recursively erasing | * Make mempool consistent after a reorg, by re-adding or recursively erasing | ||||
* disconnected block transactions from the mempool, and also removing any other | * disconnected block transactions from the mempool, and also removing any other | ||||
* transactions from the mempool that are no longer valid given the new | * transactions from the mempool that are no longer valid given the new | ||||
* tip/height. | * tip/height. | ||||
* | * | ||||
* Note: we assume that disconnectpool only contains transactions that are NOT | * Note: we assume that disconnectpool only contains transactions that are NOT | ||||
* confirmed in the current chain nor already in the mempool (otherwise, | * confirmed in the current chain nor already in the mempool (otherwise, | ||||
▲ Show 20 Lines • Show All 2,947 Lines • ▼ Show 20 Lines | static bool ContextualCheckBlock(const Config &config, const CBlock &block, | ||||
// Start enforcing BIP113 (Median Time Past) using versionbits logic. | // Start enforcing BIP113 (Median Time Past) using versionbits logic. | ||||
int nLockTimeFlags = 0; | int nLockTimeFlags = 0; | ||||
if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV, | if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV, | ||||
versionbitscache) == THRESHOLD_ACTIVE) { | versionbitscache) == THRESHOLD_ACTIVE) { | ||||
nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST; | nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST; | ||||
} | } | ||||
if (!IsMonolithEnabled(config, pindexPrev)) { | |||||
// When the May 15, 2018 HF is not enabled, block cannot be bigger | |||||
// than 8MB . | |||||
const uint64_t currentBlockSize = | |||||
::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION); | |||||
if (currentBlockSize > 8 * ONE_MEGABYTE) { | |||||
return state.DoS(100, false, REJECT_INVALID, "bad-blk-length", | |||||
false, "size limits failed"); | |||||
} | |||||
} | |||||
const int64_t nMedianTimePast = | const int64_t nMedianTimePast = | ||||
pindexPrev == nullptr ? 0 : pindexPrev->GetMedianTimePast(); | pindexPrev == nullptr ? 0 : pindexPrev->GetMedianTimePast(); | ||||
const int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) | const int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) | ||||
? nMedianTimePast | ? nMedianTimePast | ||||
: block.GetBlockTime(); | : block.GetBlockTime(); | ||||
// Check that all transactions are finalized | // Check that all transactions are finalized | ||||
▲ Show 20 Lines • Show All 1,746 Lines • Show Last 20 Lines |