Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 606 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 IsMagneticAnomalyEnabled(const Config &config, | |||||
int64_t nMedianTimePast) { | |||||
return nMedianTimePast >= gArgs.GetArg("-magneticanomalyactivationtime", | |||||
config.GetChainParams() | |||||
.GetConsensus() | |||||
.magneticAnomalyActivationTime); | |||||
} | |||||
bool IsMagneticAnomalyEnabled(const Config &config, | |||||
const CBlockIndex *pindexPrev) { | |||||
if (pindexPrev == nullptr) { | |||||
return false; | |||||
} | |||||
return IsMagneticAnomalyEnabled(config, pindexPrev->GetMedianTimePast()); | |||||
} | |||||
static bool IsReplayProtectionEnabled(const Config &config, | static bool IsReplayProtectionEnabled(const Config &config, | ||||
int64_t nMedianTimePast) { | int64_t nMedianTimePast) { | ||||
return nMedianTimePast >= gArgs.GetArg("-replayprotectionactivationtime", | return nMedianTimePast >= gArgs.GetArg("-replayprotectionactivationtime", | ||||
config.GetChainParams() | config.GetChainParams() | ||||
.GetConsensus() | .GetConsensus() | ||||
.magneticAnomalyActivationTime); | .magneticAnomalyActivationTime); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,508 Lines • ▼ Show 20 Lines | static bool ConnectBlock(const Config &config, const CBlock &block, | ||||
int nLockTimeFlags = 0; | int nLockTimeFlags = 0; | ||||
if (VersionBitsState(pindex->pprev, consensusParams, | if (VersionBitsState(pindex->pprev, consensusParams, | ||||
Consensus::DEPLOYMENT_CSV, | Consensus::DEPLOYMENT_CSV, | ||||
versionbitscache) == THRESHOLD_ACTIVE) { | versionbitscache) == THRESHOLD_ACTIVE) { | ||||
nLockTimeFlags |= LOCKTIME_VERIFY_SEQUENCE; | nLockTimeFlags |= LOCKTIME_VERIFY_SEQUENCE; | ||||
} | } | ||||
const uint32_t flags = GetBlockScriptFlags(config, pindex->pprev); | const uint32_t flags = GetBlockScriptFlags(config, pindex->pprev); | ||||
const bool fIsMagneticAnomalyEnabled = | |||||
IsMagneticAnomalyEnabled(config, pindex->pprev); | |||||
int64_t nTime2 = GetTimeMicros(); | int64_t nTime2 = GetTimeMicros(); | ||||
nTimeForks += nTime2 - nTime1; | nTimeForks += nTime2 - nTime1; | ||||
LogPrint(BCLog::BENCH, " - Fork checks: %.2fms [%.2fs]\n", | LogPrint(BCLog::BENCH, " - Fork checks: %.2fms [%.2fs]\n", | ||||
0.001 * (nTime2 - nTime1), nTimeForks * 0.000001); | 0.001 * (nTime2 - nTime1), nTimeForks * 0.000001); | ||||
CBlockUndo blockundo; | CBlockUndo blockundo; | ||||
Show All 22 Lines | for (const auto &ptx : block.vtx) { | ||||
nInputs += tx.vin.size(); | nInputs += tx.vin.size(); | ||||
vPos.push_back(std::make_pair(tx.GetId(), pos)); | vPos.push_back(std::make_pair(tx.GetId(), pos)); | ||||
pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); | pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); | ||||
if (tx.IsCoinBase()) { | if (tx.IsCoinBase()) { | ||||
// We've already checked for sigops count before P2SH in CheckBlock. | // We've already checked for sigops count before P2SH in CheckBlock. | ||||
nSigOpsCount += GetSigOpCountWithoutP2SH(tx); | nSigOpsCount += GetSigOpCountWithoutP2SH(tx); | ||||
} | |||||
if (fIsMagneticAnomalyEnabled || tx.IsCoinBase()) { | |||||
AddCoins(view, tx, pindex->nHeight); | AddCoins(view, tx, pindex->nHeight); | ||||
} | } | ||||
} | } | ||||
for (const auto &ptx : block.vtx) { | for (const auto &ptx : block.vtx) { | ||||
const CTransaction &tx = *ptx; | const CTransaction &tx = *ptx; | ||||
if (tx.IsCoinBase()) { | if (tx.IsCoinBase()) { | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | for (const auto &ptx : block.vtx) { | ||||
return error("ConnectBlock(): CheckInputs on %s failed with %s", | return error("ConnectBlock(): CheckInputs on %s failed with %s", | ||||
tx.GetId().ToString(), FormatStateMessage(state)); | tx.GetId().ToString(), FormatStateMessage(state)); | ||||
} | } | ||||
control.Add(vChecks); | control.Add(vChecks); | ||||
blockundo.vtxundo.push_back(CTxUndo()); | blockundo.vtxundo.push_back(CTxUndo()); | ||||
SpendCoins(view, tx, blockundo.vtxundo.back(), pindex->nHeight); | SpendCoins(view, tx, blockundo.vtxundo.back(), pindex->nHeight); | ||||
if (!fIsMagneticAnomalyEnabled) { | |||||
AddCoins(view, tx, pindex->nHeight); | AddCoins(view, tx, pindex->nHeight); | ||||
} | } | ||||
} | |||||
int64_t nTime3 = GetTimeMicros(); | int64_t nTime3 = GetTimeMicros(); | ||||
nTimeConnect += nTime3 - nTime2; | nTimeConnect += nTime3 - nTime2; | ||||
LogPrint(BCLog::BENCH, | LogPrint(BCLog::BENCH, | ||||
" - Connect %u transactions: %.2fms (%.3fms/tx, " | " - Connect %u transactions: %.2fms (%.3fms/tx, " | ||||
"%.3fms/txin) [%.2fs]\n", | "%.3fms/txin) [%.2fs]\n", | ||||
(unsigned)block.vtx.size(), 0.001 * (nTime3 - nTime2), | (unsigned)block.vtx.size(), 0.001 * (nTime3 - nTime2), | ||||
0.001 * (nTime3 - nTime2) / block.vtx.size(), | 0.001 * (nTime3 - nTime2) / block.vtx.size(), | ||||
▲ Show 20 Lines • Show All 3,282 Lines • Show Last 20 Lines |