Bitcoin Core  25.99.0
P2P Digital Currency
txmempool.cpp
Go to the documentation of this file.
1 // Copyright (c) 2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <test/util/txmempool.h>
6 
7 #include <chainparams.h>
8 #include <node/context.h>
9 #include <node/mempool_args.h>
10 #include <txmempool.h>
11 #include <util/check.h>
12 #include <util/time.h>
13 #include <util/translation.h>
14 
15 using node::NodeContext;
16 
18 {
19  CTxMemPool::Options mempool_opts{
20  .estimator = node.fee_estimator.get(),
21  // Default to always checking mempool regardless of
22  // chainparams.DefaultConsistencyChecks for tests
23  .check_ratio = 1,
24  };
25  const auto result{ApplyArgsManOptions(*node.args, ::Params(), mempool_opts)};
26  Assert(result);
27  return mempool_opts;
28 }
29 
31 {
32  return FromTx(MakeTransactionRef(tx));
33 }
34 
36 {
37  return CTxMemPoolEntry{tx, nFee, TicksSinceEpoch<std::chrono::seconds>(time), nHeight, spendsCoinbase, sigOpCost, lp};
38 }
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Definition: check.h:73
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition: mempool_entry.h:66
Definition: init.h:25
util::Result< void > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition: transaction.h:422
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:421
A mutable version of CTransaction.
Definition: transaction.h:380
CAmount nFee
Definition: txmempool.h:19
bool spendsCoinbase
Definition: txmempool.h:22
LockPoints lp
Definition: txmempool.h:24
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
Definition: txmempool.cpp:30
unsigned int nHeight
Definition: txmempool.h:21
unsigned int sigOpCost
Definition: txmempool.h:23
NodeSeconds time
Definition: txmempool.h:20
Options struct containing options for constructing a CTxMemPool.
CBlockPolicyEstimator * estimator
NodeContext struct containing references to chain state and connection state.
Definition: context.h:45
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
Definition: txmempool.cpp:17