Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 698 Lines • ▼ Show 20 Lines | Amount mempoolRejectFee = | ||||
.GetFee(ws.m_vsize); | .GetFee(ws.m_vsize); | ||||
if (!bypass_limits && mempoolRejectFee > Amount::zero() && | if (!bypass_limits && mempoolRejectFee > Amount::zero() && | ||||
ws.m_modified_fees < mempoolRejectFee) { | ws.m_modified_fees < mempoolRejectFee) { | ||||
return state.Invalid( | return state.Invalid( | ||||
TxValidationResult::TX_MEMPOOL_POLICY, "mempool min fee not met", | TxValidationResult::TX_MEMPOOL_POLICY, "mempool min fee not met", | ||||
strprintf("%d < %d", ws.m_modified_fees, mempoolRejectFee)); | strprintf("%d < %d", ws.m_modified_fees, mempoolRejectFee)); | ||||
} | } | ||||
// Remove after wellington | |||||
if (!m_pool.wellingtonLatched) { | |||||
// Calculate in-mempool ancestors, up to a limit. | |||||
std::string errString; | |||||
if (!m_pool.CalculateMemPoolAncestors( | |||||
*entry, ws.m_ancestors, m_limit_ancestors, | |||||
m_limit_ancestor_size, m_limit_descendants, | |||||
m_limit_descendant_size, errString)) { | |||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, | |||||
"too-long-mempool-chain", errString); | |||||
} | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
bool MemPoolAccept::PackageMempoolChecks( | bool MemPoolAccept::PackageMempoolChecks( | ||||
const std::vector<CTransactionRef> &txns, | const std::vector<CTransactionRef> &txns, | ||||
PackageValidationState &package_state) { | PackageValidationState &package_state) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
AssertLockHeld(m_pool.cs); | AssertLockHeld(m_pool.cs); | ||||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | MemPoolAccept::AcceptSingleTransaction(const CTransactionRef &ptx, | ||||
// mempool "read lock" (held through | // mempool "read lock" (held through | ||||
// GetMainSignals().TransactionAddedToMempool()) | // GetMainSignals().TransactionAddedToMempool()) | ||||
LOCK(m_pool.cs); | LOCK(m_pool.cs); | ||||
const Consensus::Params &consensusParams = | const Consensus::Params &consensusParams = | ||||
args.m_config.GetChainParams().GetConsensus(); | args.m_config.GetChainParams().GetConsensus(); | ||||
const CBlockIndex *tip = m_active_chainstate.m_chain.Tip(); | const CBlockIndex *tip = m_active_chainstate.m_chain.Tip(); | ||||
// After wellington we will stop computing the ancestors and descendant | |||||
// limits, and stop enforcing them. Because the mempool has no idea what the | |||||
// current tip is (and it should not), we will use an activation latch so it | |||||
// knows when the statistics can be skipped. This also makes an hypothetical | |||||
// reorg event easier to handle. | |||||
// Note that |= operator is not defined for atomic bool ! | |||||
m_pool.wellingtonLatched = | |||||
m_pool.wellingtonLatched || IsWellingtonEnabled(consensusParams, tip); | |||||
Workspace ws(ptx, GetNextBlockScriptFlags(consensusParams, tip)); | Workspace ws(ptx, GetNextBlockScriptFlags(consensusParams, tip)); | ||||
// Perform the inexpensive checks first and avoid hashing and signature | // Perform the inexpensive checks first and avoid hashing and signature | ||||
// verification unless those checks pass, to mitigate CPU exhaustion | // verification unless those checks pass, to mitigate CPU exhaustion | ||||
// denial-of-service attacks. | // denial-of-service attacks. | ||||
if (!PreChecks(args, ws)) { | if (!PreChecks(args, ws)) { | ||||
return MempoolAcceptResult::Failure(ws.m_state); | return MempoolAcceptResult::Failure(ws.m_state); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 5,304 Lines • Show Last 20 Lines |