Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 685 Lines • ▼ Show 20 Lines | MemPoolAccept::AcceptSingleTransaction(const CTransactionRef &ptx, | ||||
// GetMainSignals().TransactionAddedToMempool()) | // GetMainSignals().TransactionAddedToMempool()) | ||||
LOCK(m_pool.cs); | LOCK(m_pool.cs); | ||||
Workspace ws(ptx, GetNextBlockScriptFlags( | Workspace ws(ptx, GetNextBlockScriptFlags( | ||||
args.m_config.GetChainParams().GetConsensus(), | args.m_config.GetChainParams().GetConsensus(), | ||||
m_active_chainstate.m_chain.Tip())); | m_active_chainstate.m_chain.Tip())); | ||||
if (!PreChecks(args, ws)) { | if (!PreChecks(args, ws)) { | ||||
return MempoolAcceptResult(ws.m_state); | return MempoolAcceptResult::Failure(ws.m_state); | ||||
} | } | ||||
// Only compute the precomputed transaction data if we need to verify | // Only compute the precomputed transaction data if we need to verify | ||||
// scripts (ie, other policy checks pass). We perform the inexpensive | // scripts (ie, other policy checks pass). We perform the inexpensive | ||||
// checks first and avoid hashing and signature verification unless those | // checks first and avoid hashing and signature verification unless those | ||||
// checks pass, to mitigate CPU exhaustion denial-of-service attacks. | // checks pass, to mitigate CPU exhaustion denial-of-service attacks. | ||||
PrecomputedTransactionData txdata(*ptx); | PrecomputedTransactionData txdata(*ptx); | ||||
if (!ConsensusScriptChecks(args, ws, txdata)) { | if (!ConsensusScriptChecks(args, ws, txdata)) { | ||||
return MempoolAcceptResult(ws.m_state); | return MempoolAcceptResult::Failure(ws.m_state); | ||||
} | } | ||||
// Tx was accepted, but not added | // Tx was accepted, but not added | ||||
if (args.m_test_accept) { | if (args.m_test_accept) { | ||||
return MempoolAcceptResult(ws.m_base_fees); | return MempoolAcceptResult::Success(ws.m_base_fees); | ||||
} | } | ||||
if (!Finalize(args, ws)) { | if (!Finalize(args, ws)) { | ||||
return MempoolAcceptResult(ws.m_state); | return MempoolAcceptResult::Failure(ws.m_state); | ||||
} | } | ||||
GetMainSignals().TransactionAddedToMempool( | GetMainSignals().TransactionAddedToMempool( | ||||
ptx, m_pool.GetAndIncrementSequence()); | ptx, m_pool.GetAndIncrementSequence()); | ||||
return MempoolAcceptResult(ws.m_base_fees); | return MempoolAcceptResult::Success(ws.m_base_fees); | ||||
} | } | ||||
} // namespace | } // namespace | ||||
/** | /** | ||||
* (try to) add transaction to memory pool with a specified acceptance time. | * (try to) add transaction to memory pool with a specified acceptance time. | ||||
*/ | */ | ||||
static MempoolAcceptResult AcceptToMemoryPoolWithTime( | static MempoolAcceptResult AcceptToMemoryPoolWithTime( | ||||
▲ Show 20 Lines • Show All 5,360 Lines • Show Last 20 Lines |