9#include <test/util/setup_common.h>
12#include <validation.h>
34static std::vector<CTransactionRef>
37 std::vector<Available> available_coins;
38 std::vector<CTransactionRef> ordered_coins;
40 size_t tx_counter = 1;
41 for (
auto x = 0; x < 100; ++x) {
46 for (
auto &out : tx.
vout) {
48 out.nValue = 10 *
COIN;
51 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
53 for (
auto x = 0; x < childTxs && !available_coins.empty(); ++x) {
55 size_t n_ancestors = det_rand.
randrange(10) + 1;
56 for (
size_t ancestor = 0;
57 ancestor < n_ancestors && !available_coins.empty(); ++ancestor) {
58 size_t idx = det_rand.
randrange(available_coins.size());
65 : min_ancestors + det_rand.
randrange(coin.
ref->vout.size() -
67 for (
size_t i = 0; i < n_to_take; ++i) {
68 tx.
vin.emplace_back();
69 tx.
vin.back().prevout = COutPoint(txid, coin.
vin_left++);
70 tx.
vin.back().scriptSig = CScript() << coin.
tx_count;
73 coin = available_coins.back();
74 available_coins.pop_back();
77 for (
auto &out : tx.
vout) {
78 out.scriptPubKey = CScript()
80 out.nValue = 10 *
COIN;
84 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
95 std::vector<CTransactionRef> ordered_coins =
97 const auto testing_setup =
102 for (
auto &tx : ordered_coins) {
112 auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(
116 testing_setup->PopulateMempool(det_rand, 400,
true);
118 testing_setup.get()->m_node.chainman->ActiveChainstate().CoinsTip();
123 pool.check(coins_tip, 300);
static constexpr Amount SATOSHI
static constexpr Amount COIN
CCoinsView that adds a memory cache for transactions to another CCoinsView.
A mutable version of CTransaction.
std::vector< CTxOut > vout
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
size_t DynamicMemoryUsage() const
CTransactionRef get(const TxId &txid) const
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void addUnchecked(CTxMemPoolEntryRef entry) EXCLUSIVE_LOCKS_REQUIRED(cs
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).
static RCUPtr make(Args &&...args)
Construct a new object that is owned by the pointer.
Main entry point to nanobench's benchmarking facility.
Bench & complexityN(T b) noexcept
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
static void AddTx(const CTransactionRef &tx, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
static void MempoolCheck(benchmark::Bench &bench)
static std::vector< CTransactionRef > CreateOrderedCoins(FastRandomContext &det_rand, int childTxs, int min_ancestors)
BENCHMARK(ComplexMemPool)
static void ComplexMemPool(benchmark::Bench &bench)
int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigChecks, unsigned int bytes_per_sigCheck)
Compute the virtual transaction size (size, or more if sigChecks are too dense).
static CTransactionRef MakeTransactionRef()
std::shared_ptr< const CTransaction > CTransactionRef
Available(CTransactionRef &_ref, size_t _tx_count)
A TxId is the identifier of a transaction.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define NO_THREAD_SAFETY_ANALYSIS