8 #include <test/util/setup_common.h> 21 spendsCoinbase, sigOpCost, lp));
29 : ref(_ref), tx_count(_tx_count) {}
34 std::vector<Available> available_coins;
35 std::vector<CTransactionRef> ordered_coins;
37 size_t tx_counter = 1;
38 for (
auto x = 0; x < 100; ++x) {
42 tx.
vout.resize(det_rand.randrange(10) + 2);
43 for (
auto &out : tx.
vout) {
45 out.nValue = 10 *
COIN;
48 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
50 for (
auto x = 0; x < 800 && !available_coins.empty(); ++x) {
52 size_t n_ancestors = det_rand.randrange(10) + 1;
53 for (
size_t ancestor = 0;
54 ancestor < n_ancestors && !available_coins.empty(); ++ancestor) {
55 size_t idx = det_rand.randrange(available_coins.size());
60 det_rand.randrange(2) == 0
62 : 1 + det_rand.randrange(coin.
ref->vout.size() -
64 for (
size_t i = 0; i < n_to_take; ++i) {
65 tx.
vin.emplace_back();
70 coin = available_coins.back();
71 available_coins.pop_back();
73 tx.
vout.resize(det_rand.randrange(10) + 2);
74 for (
auto &out : tx.
vout) {
77 out.nValue = 10 *
COIN;
81 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
83 TestingSetup test_setup;
87 for (
auto &tx : ordered_coins) {
std::shared_ptr< const CTransaction > CTransactionRef
static void ComplexMemPool(benchmark::State &state)
Available(CTransactionRef &_ref, size_t _tx_count)
size_t DynamicMemoryUsage() const
static CTransactionRef MakeTransactionRef()
static constexpr Amount SATOSHI
std::vector< CTxOut > vout
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
static constexpr Amount COIN
RecursiveMutex cs_main
Global state.
An outpoint - a combination of a transaction hash and an index n into its vout.
void addUnchecked(const CTxMemPoolEntry &entry) EXCLUSIVE_LOCKS_REQUIRED(cs
#define EXCLUSIVE_LOCKS_REQUIRED(...)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Serialized script, used inside transaction inputs and outputs.
A TxId is the identifier of a transaction.
A mutable version of CTransaction.
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.
BENCHMARK(ComplexMemPool, 1)
int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigOpCount, unsigned int bytes_per_sigop)
Compute the virtual transaction size (size, or more if sigops are too dense).
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
static void AddTx(const CTransactionRef &tx, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main