@@ -56,7 +56,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
56
56
size_t n_ancestors = det_rand.randrange (10 )+1 ;
57
57
for (size_t ancestor = 0 ; ancestor < n_ancestors && !available_coins.empty (); ++ancestor){
58
58
size_t idx = det_rand.randrange (available_coins.size ());
59
- Available& coin = available_coins[idx];
59
+ Available coin = available_coins[idx];
60
60
uint256 hash = coin.ref ->GetHash ();
61
61
// biased towards taking just one ancestor, but maybe more
62
62
size_t n_to_take = det_rand.randrange (2 ) == 0 ? 1 : 1 +det_rand.randrange (coin.ref ->vout .size () - coin.vin_left );
@@ -66,17 +66,15 @@ static void ComplexMemPool(benchmark::Bench& bench)
66
66
tx.vin .back ().scriptSig = CScript () << coin.tx_count ;
67
67
tx.vin .back ().scriptWitness .stack .push_back (CScriptNum (coin.tx_count ).getvch ());
68
68
}
69
- if (coin.vin_left == coin.ref ->vout .size ()) {
70
- if (available_coins.size ()-1 !=idx){ // if idx is not the last index swap it with the end index
71
- std::swap (available_coins[idx], available_coins.back ());
72
- }
69
+ if (coin.vin_left == coin.ref ->vin .size ()) {
70
+ coin = available_coins.back ();
73
71
available_coins.pop_back ();
74
72
}
75
- }
76
- tx.vout . resize (det_rand. randrange ( 10 )+ 2 );
77
- for ( auto & out : tx. vout ) {
78
- out.scriptPubKey = CScript () << CScriptNum (tx_counter) << OP_EQUAL ;
79
- out. nValue = 10 * COIN;
73
+ tx. vout . resize (det_rand. randrange ( 10 )+ 2 );
74
+ for ( auto & out : tx.vout ) {
75
+ out. scriptPubKey = CScript () << CScriptNum (tx_counter) << OP_EQUAL;
76
+ out.nValue = 10 * COIN ;
77
+ }
80
78
}
81
79
ordered_coins.emplace_back (MakeTransactionRef (tx));
82
80
available_coins.emplace_back (ordered_coins.back (), tx_counter++);
0 commit comments