mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
[validation] Add CChainState::ProcessTransaction()
This just calls through to AcceptToMemoryPool() internally, and is currently unused. Also add a new transaction validation failure reason TX_NO_MEMPOOL to indicate that there is no mempool.
This commit is contained in:
parent
36167faea9
commit
92a3aeecf6
4 changed files with 22 additions and 0 deletions
|
@ -53,6 +53,7 @@ enum class TxValidationResult {
|
|||
*/
|
||||
TX_CONFLICT,
|
||||
TX_MEMPOOL_POLICY, //!< violated mempool's fee/size/descendant/RBF/etc limits
|
||||
TX_NO_MEMPOOL, //!< this node does not have a mempool so can't validate the transaction
|
||||
};
|
||||
|
||||
/** A "reason" why a block was invalid, suitable for determining whether the
|
||||
|
|
|
@ -1409,6 +1409,7 @@ bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
|
|||
case TxValidationResult::TX_WITNESS_STRIPPED:
|
||||
case TxValidationResult::TX_CONFLICT:
|
||||
case TxValidationResult::TX_MEMPOOL_POLICY:
|
||||
case TxValidationResult::TX_NO_MEMPOOL:
|
||||
break;
|
||||
}
|
||||
if (message != "") {
|
||||
|
|
|
@ -3421,6 +3421,17 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s
|
|||
return true;
|
||||
}
|
||||
|
||||
MempoolAcceptResult ChainstateManager::ProcessTransaction(const CTransactionRef& tx, bool test_accept)
|
||||
{
|
||||
CChainState& active_chainstate = ActiveChainstate();
|
||||
if (!active_chainstate.m_mempool) {
|
||||
TxValidationState state;
|
||||
state.Invalid(TxValidationResult::TX_NO_MEMPOOL, "no-mempool");
|
||||
return MempoolAcceptResult::Failure(state);
|
||||
}
|
||||
return AcceptToMemoryPool(active_chainstate, *active_chainstate.m_mempool, tx, /*bypass_limits=*/ false, test_accept);
|
||||
}
|
||||
|
||||
bool TestBlockValidity(BlockValidationState& state,
|
||||
const CChainParams& chainparams,
|
||||
CChainState& chainstate,
|
||||
|
|
|
@ -994,6 +994,15 @@ public:
|
|||
*/
|
||||
bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& block, BlockValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex = nullptr) LOCKS_EXCLUDED(cs_main);
|
||||
|
||||
/**
|
||||
* Try to add a transaction to the memory pool.
|
||||
*
|
||||
* @param[in] tx The transaction to submit for mempool acceptance.
|
||||
* @param[in] test_accept When true, run validation checks but don't submit to mempool.
|
||||
*/
|
||||
[[nodiscard]] MempoolAcceptResult ProcessTransaction(const CTransactionRef& tx, bool test_accept=false)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
//! Load the block tree and coins database from disk, initializing state if we're running with -reindex
|
||||
bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue