Skip to content

Commit faa185b

Browse files
author
MarcoFalke
committed
Revert "Fixes Bug in Transaction generation in ComplexMempool benchmark"
This reverts commit 29e9833.
1 parent 29e9833 commit faa185b

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/bench/mempool_stress.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
5656
size_t n_ancestors = det_rand.randrange(10)+1;
5757
for (size_t ancestor = 0; ancestor < n_ancestors && !available_coins.empty(); ++ancestor){
5858
size_t idx = det_rand.randrange(available_coins.size());
59-
Available& coin = available_coins[idx];
59+
Available coin = available_coins[idx];
6060
uint256 hash = coin.ref->GetHash();
6161
// biased towards taking just one ancestor, but maybe more
6262
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)
6666
tx.vin.back().scriptSig = CScript() << coin.tx_count;
6767
tx.vin.back().scriptWitness.stack.push_back(CScriptNum(coin.tx_count).getvch());
6868
}
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();
7371
available_coins.pop_back();
7472
}
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+
}
8078
}
8179
ordered_coins.emplace_back(MakeTransactionRef(tx));
8280
available_coins.emplace_back(ordered_coins.back(), tx_counter++);

0 commit comments

Comments
 (0)