Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 3,719 Lines • ▼ Show 20 Lines | static bool ContextualCheckBlock(const Config &config, const CBlock &block, | ||||
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(); | ||||
const bool fIsMagneticAnomalyEnabled = | |||||
IsMagneticAnomalyEnabled(config, pindexPrev); | |||||
// Check that all transactions are finalized | // Check that all transactions are finalized | ||||
for (const auto &tx : block.vtx) { | const CTransaction *prevTx = nullptr; | ||||
if (!ContextualCheckTransaction(config, *tx, state, nHeight, | for (const auto &ptx : block.vtx) { | ||||
const CTransaction &tx = *ptx; | |||||
if (fIsMagneticAnomalyEnabled) { | |||||
if (prevTx && (tx.GetId() < prevTx->GetId())) { | |||||
return state.DoS( | |||||
100, false, REJECT_INVALID, "tx-ordering", false, | |||||
strprintf("Transaction order is invalid (%s < %s)", | |||||
tx.GetId().ToString(), | |||||
prevTx->GetId().ToString())); | |||||
} | |||||
if (prevTx || !tx.IsCoinBase()) { | |||||
prevTx = &tx; | |||||
} | |||||
} | |||||
if (!ContextualCheckTransaction(config, tx, state, nHeight, | |||||
nLockTimeCutoff)) { | nLockTimeCutoff)) { | ||||
// state set by ContextualCheckTransaction. | // state set by ContextualCheckTransaction. | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// Enforce rule that the coinbase starts with serialized block height | // Enforce rule that the coinbase starts with serialized block height | ||||
if (nHeight >= consensusParams.BIP34Height) { | if (nHeight >= consensusParams.BIP34Height) { | ||||
▲ Show 20 Lines • Show All 1,830 Lines • Show Last 20 Lines |