Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115278
D12238.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Subscribers
None
D12238.diff
View Options
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -1464,8 +1464,9 @@
reverse_iterate(queuedTx.get<insertion_order>())) {
// ignore validation errors in resurrected transactions
if (!fAddToMempool || tx->IsCoinBase() ||
- AcceptToMemoryPool(active_chainstate, config, pool, tx,
- true /* bypass_limits */)
+ AcceptToMemoryPool(config, pool, active_chainstate, tx, GetTime(),
+ /* bypass_limits= */ true,
+ /* test_accept= */ false)
.m_result_type != MempoolAcceptResult::ResultType::VALID) {
// If the transaction doesn't make it in to the mempool, remove any
// transactions that depend on it (which would now be orphans).
diff --git a/src/validation.h b/src/validation.h
--- a/src/validation.h
+++ b/src/validation.h
@@ -333,11 +333,16 @@
* exposed only for testing. Client code should use
* ChainstateManager::ProcessTransaction()
*
- * @param[in] active_chainstate Reference to the active chainstate.
- * @param[in] pool Reference to the node's mempool.
* @param[in] config The global configuration.
+ * @param[in] pool Reference to the node's mempool.
+ * @param[in] active_chainstate Reference to the active chainstate.
* @param[in] tx The transaction to submit for mempool
* acceptance.
+ * @param[in] accept_time The timestamp for adding the transaction to
+ * the mempool. Usually the current system time,
+ * but may be different.
+ * It is also used to determine when the entry
+ * expires.
* @param[in] bypass_limits When true, don't enforce mempool fee and
* capacity limits.
* @param[in] test_accept When true, run validation checks but don't
@@ -346,10 +351,11 @@
* @returns a MempoolAcceptResult indicating whether the transaction was
* accepted/rejected with reason.
*/
-MempoolAcceptResult
-AcceptToMemoryPool(CChainState &active_chainstate, const Config &config,
- CTxMemPool &pool, const CTransactionRef &tx,
- bool bypass_limits, bool test_accept = false)
+MempoolAcceptResult AcceptToMemoryPool(const Config &config, CTxMemPool &pool,
+ CChainState &active_chainstate,
+ const CTransactionRef &tx,
+ int64_t accept_time, bool bypass_limits,
+ bool test_accept = false)
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/**
@@ -845,8 +851,6 @@
//! Only the active chainstate has a mempool.
CTxMemPool *m_mempool;
- const CChainParams &m_params;
-
//! Manages the UTXO set, which is a reflection of the contents of
//! `m_chain`.
std::unique_ptr<CoinsViews> m_coins_views;
@@ -871,6 +875,9 @@
//! CChainState instances.
BlockManager &m_blockman;
+ /** Chain parameters for this chainstate */
+ const CChainParams &m_params;
+
explicit CChainState(
CTxMemPool *mempool, BlockManager &blockman,
std::optional<BlockHash> from_snapshot_blockhash = std::nullopt);
diff --git a/src/validation.cpp b/src/validation.cpp
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -804,16 +804,14 @@
} // namespace
-/**
- * (try to) add transaction to memory pool with a specified acceptance time.
- */
-static MempoolAcceptResult AcceptToMemoryPoolWithTime(
- const Config &config, CTxMemPool &pool, CChainState &active_chainstate,
- const CTransactionRef &tx, int64_t nAcceptTime, bool bypass_limits,
- bool test_accept) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
+MempoolAcceptResult AcceptToMemoryPool(const Config &config, CTxMemPool &pool,
+ CChainState &active_chainstate,
+ const CTransactionRef &tx,
+ int64_t accept_time, bool bypass_limits,
+ bool test_accept) {
AssertLockHeld(cs_main);
std::vector<COutPoint> coins_to_uncache;
- MemPoolAccept::ATMPArgs args{config, nAcceptTime, bypass_limits,
+ MemPoolAccept::ATMPArgs args{config, accept_time, bypass_limits,
coins_to_uncache, test_accept};
const MempoolAcceptResult result = MemPoolAccept(pool, active_chainstate)
.AcceptSingleTransaction(tx, args);
@@ -836,14 +834,6 @@
return result;
}
-MempoolAcceptResult AcceptToMemoryPool(CChainState &active_chainstate,
- const Config &config, CTxMemPool &pool,
- const CTransactionRef &tx,
- bool bypass_limits, bool test_accept) {
- return AcceptToMemoryPoolWithTime(config, pool, active_chainstate, tx,
- GetTime(), bypass_limits, test_accept);
-}
-
PackageMempoolAcceptResult
ProcessNewPackage(const Config &config, CChainState &active_chainstate,
CTxMemPool &pool, const Package &package, bool test_accept) {
@@ -929,7 +919,7 @@
CChainState::CChainState(CTxMemPool *mempool, BlockManager &blockman,
std::optional<BlockHash> from_snapshot_blockhash)
- : m_mempool(mempool), m_params(::Params()), m_blockman(blockman),
+ : m_mempool(mempool), m_blockman(blockman), m_params(::Params()),
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
void CChainState::InitCoinsDB(size_t cache_size_bytes, bool in_memory,
@@ -4287,9 +4277,10 @@
// making AcceptToMemoryPool take a CChainParams instead of a Config.
// This avoids passing an extra Config argument to this function that will
// be removed soon.
- auto result = AcceptToMemoryPool(active_chainstate, ::GetConfig(),
- *active_chainstate.m_mempool, tx,
- /*bypass_limits=*/false, test_accept);
+ auto result =
+ AcceptToMemoryPool(::GetConfig(), *active_chainstate.m_mempool,
+ active_chainstate, tx, GetTime(),
+ /* bypass_limits= */ false, test_accept);
active_chainstate.m_mempool->check(active_chainstate.CoinsTip(),
active_chainstate.m_chain.Height() + 1);
return result;
@@ -5635,9 +5626,9 @@
}
if (nTime > nNow - nExpiryTimeout) {
LOCK(cs_main);
- if (AcceptToMemoryPoolWithTime(
- config, pool, active_chainstate, tx, nTime,
- false /* bypass_limits */, false /* test_accept */)
+ if (AcceptToMemoryPool(config, pool, active_chainstate, tx,
+ nTime, /* bypass_limits= */ false,
+ /* test_accept= */ false)
.m_result_type ==
MempoolAcceptResult::ResultType::VALID) {
++count;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 10:37 (11 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187375
Default Alt Text
D12238.diff (7 KB)
Attached To
D12238: Remove AcceptToMemoryPoolWithTime
Event Timeline
Log In to Comment