@@ -47,10 +47,17 @@ void generateFakeBlock(const CChainParams& params,
47
47
coinbase_tx.vin [0 ].prevout .SetNull ();
48
48
coinbase_tx.vout .resize (2 );
49
49
coinbase_tx.vout [0 ].scriptPubKey = coinbase_out_script;
50
- coinbase_tx.vout [0 ].nValue = 49 * COIN;
50
+ coinbase_tx.vout [0 ].nValue = 48 * COIN;
51
51
coinbase_tx.vin [0 ].scriptSig = CScript () << ++tip.tip_height << OP_0;
52
52
coinbase_tx.vout [1 ].scriptPubKey = coinbase_out_script; // extra output
53
53
coinbase_tx.vout [1 ].nValue = 1 * COIN;
54
+
55
+ // Fill the coinbase with outputs that don't belong to the wallet in order to benchmark
56
+ // AvailableCoins' behavior with unnecessary TXOs
57
+ for (int i = 0 ; i < 50 ; ++i) {
58
+ coinbase_tx.vout .push_back (CTxOut (1 * COIN / 50 , CScript (OP_TRUE)));
59
+ }
60
+
54
61
block.vtx = {MakeTransactionRef (std::move (coinbase_tx))};
55
62
56
63
block.nVersion = VERSIONBITS_LAST_OLD_BLOCK_VERSION;
@@ -105,14 +112,14 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type
105
112
106
113
// Check available balance
107
114
auto bal = WITH_LOCK (wallet.cs_wallet , return wallet::AvailableCoins (wallet).GetTotalAmount ()); // Cache
108
- assert (bal == 50 * COIN * (chain_size - COINBASE_MATURITY));
115
+ assert (bal == 49 * COIN * (chain_size - COINBASE_MATURITY));
109
116
110
117
wallet::CCoinControl coin_control;
111
118
coin_control.m_allow_other_inputs = allow_other_inputs;
112
119
113
120
CAmount target = 0 ;
114
121
if (preset_inputs) {
115
- // Select inputs, each has 49 BTC
122
+ // Select inputs, each has 48 BTC
116
123
wallet::CoinFilterParams filter_coins;
117
124
filter_coins.max_count = preset_inputs->num_of_internal_inputs ;
118
125
const auto & res = WITH_LOCK (wallet.cs_wallet ,
@@ -144,8 +151,8 @@ static void AvailableCoins(benchmark::Bench& bench, const std::vector<OutputType
144
151
{
145
152
LOCK (wallet.cs_wallet );
146
153
wallet.SetWalletFlag (WALLET_FLAG_DESCRIPTORS);
147
- wallet.SetupDescriptorScriptPubKeyMans ();
148
154
if (wallet.LoadWallet () != DBErrors::LOAD_OK) assert (false );
155
+ wallet.SetupDescriptorScriptPubKeyMans ();
149
156
}
150
157
151
158
// Generate destinations
@@ -166,7 +173,7 @@ static void AvailableCoins(benchmark::Bench& bench, const std::vector<OutputType
166
173
167
174
// Check available balance
168
175
auto bal = WITH_LOCK (wallet.cs_wallet , return wallet::AvailableCoins (wallet).GetTotalAmount ()); // Cache
169
- assert (bal == 50 * COIN * (chain_size - COINBASE_MATURITY));
176
+ assert (bal == 49 * COIN * (chain_size - COINBASE_MATURITY));
170
177
171
178
bench.epochIterations (2 ).run ([&] {
172
179
LOCK (wallet.cs_wallet );
@@ -185,4 +192,4 @@ static void WalletAvailableCoins(benchmark::Bench& bench) { AvailableCoins(bench
185
192
186
193
BENCHMARK (WalletCreateTxUseOnlyPresetInputs, benchmark::PriorityLevel::LOW)
187
194
BENCHMARK(WalletCreateTxUsePresetInputsAndCoinSelection, benchmark::PriorityLevel::LOW)
188
- BENCHMARK(WalletAvailableCoins, benchmark::PriorityLevel::LOW);
195
+ BENCHMARK(WalletAvailableCoins, benchmark::PriorityLevel::LOW);
0 commit comments