@@ -26,14 +26,8 @@ struct Available {
26
26
Available (CTransactionRef& ref, size_t tx_count) : ref(ref), tx_count(tx_count){}
27
27
};
28
28
29
- static void ComplexMemPool (benchmark::Bench& bench )
29
+ static std::vector<CTransactionRef> CreateOrderedCoins (FastRandomContext& det_rand, int childTxs, int min_ancestors )
30
30
{
31
- int childTxs = 800 ;
32
- if (bench.complexityN () > 1 ) {
33
- childTxs = static_cast <int >(bench.complexityN ());
34
- }
35
-
36
- FastRandomContext det_rand{true };
37
31
std::vector<Available> available_coins;
38
32
std::vector<CTransactionRef> ordered_coins;
39
33
// Create some base transactions
@@ -58,8 +52,10 @@ static void ComplexMemPool(benchmark::Bench& bench)
58
52
size_t idx = det_rand.randrange (available_coins.size ());
59
53
Available coin = available_coins[idx];
60
54
uint256 hash = coin.ref ->GetHash ();
61
- // biased towards taking just one ancestor, but maybe more
62
- size_t n_to_take = det_rand.randrange (2 ) == 0 ? 1 : 1 +det_rand.randrange (coin.ref ->vout .size () - coin.vin_left );
55
+ // biased towards taking min_ancestors parents, but maybe more
56
+ size_t n_to_take = det_rand.randrange (2 ) == 0 ?
57
+ min_ancestors :
58
+ min_ancestors + det_rand.randrange (coin.ref ->vout .size () - coin.vin_left );
63
59
for (size_t i = 0 ; i < n_to_take; ++i) {
64
60
tx.vin .emplace_back ();
65
61
tx.vin .back ().prevout = COutPoint (hash, coin.vin_left ++);
@@ -79,6 +75,17 @@ static void ComplexMemPool(benchmark::Bench& bench)
79
75
ordered_coins.emplace_back (MakeTransactionRef (tx));
80
76
available_coins.emplace_back (ordered_coins.back (), tx_counter++);
81
77
}
78
+ return ordered_coins;
79
+ }
80
+
81
+ static void ComplexMemPool (benchmark::Bench& bench)
82
+ {
83
+ FastRandomContext det_rand{true };
84
+ int childTxs = 800 ;
85
+ if (bench.complexityN () > 1 ) {
86
+ childTxs = static_cast <int >(bench.complexityN ());
87
+ }
88
+ std::vector<CTransactionRef> ordered_coins = CreateOrderedCoins (det_rand, childTxs, /* min_ancestors */ 1 );
82
89
const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN);
83
90
CTxMemPool pool;
84
91
LOCK2 (cs_main, pool.cs );
0 commit comments