 |
Bitcoin Core
21.99.0
P2P Digital Currency
|
Go to the documentation of this file.
7 #include <test/util/setup_common.h>
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) {
45 tx.
vin[0].scriptWitness.stack.push_back(
CScriptNum(x).getvch());
46 tx.
vout.resize(det_rand.randrange(10)+2);
47 for (
auto& out : tx.
vout) {
49 out.nValue = 10 *
COIN;
52 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
54 for (
auto x = 0; x < childTxs && !available_coins.empty(); ++x) {
56 size_t n_ancestors = det_rand.randrange(10)+1;
57 for (
size_t ancestor = 0; ancestor < n_ancestors && !available_coins.empty(); ++ancestor){
58 size_t idx = det_rand.randrange(available_coins.size());
62 size_t n_to_take = det_rand.randrange(2) == 0 ? 1 : 1+det_rand.randrange(coin.
ref->vout.size() - coin.
vin_left);
63 for (
size_t i = 0; i < n_to_take; ++i) {
64 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) {
76 out.nValue = 10 *
COIN;
80 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
86 for (
auto& tx : ordered_coins) {
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
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.
Main entry point to nanobench's benchmarking facility.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Available(CTransactionRef &ref, size_t tx_count)
#define NO_THREAD_SAFETY_ANALYSIS
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Serialized script, used inside transaction inputs and outputs.
std::vector< unsigned char > getvch() const
static const std::string MAIN
Chain name strings.
std::vector< CTxOut > vout
Bench & complexityN(T b) noexcept
#define EXCLUSIVE_LOCKS_REQUIRED(...)
static void ComplexMemPool(benchmark::Bench &bench)
static void AddTx(const CTransactionRef &tx, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
static const CAmount COIN
size_t DynamicMemoryUsage() const
An outpoint - a combination of a transaction hash and an index n into its vout.
A mutable version of CTransaction.
BENCHMARK(ComplexMemPool)
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).