Skip to content

Commit f85b54e

Browse files
committed
bench: Add transactions directly instead of mining blocks
1 parent d94244c commit f85b54e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/bench/wallet_loading.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ using wallet::DatabaseOptions;
2121
using wallet::DatabaseStatus;
2222
using wallet::ISMINE_SPENDABLE;
2323
using wallet::MakeWalletDatabase;
24+
using wallet::TxStateInactive;
2425
using wallet::WALLET_FLAG_DESCRIPTORS;
2526
using wallet::WalletContext;
2627

@@ -46,6 +47,19 @@ static void BenchUnloadWallet(std::shared_ptr<CWallet>&& wallet)
4647
UnloadWallet(std::move(wallet));
4748
}
4849

50+
static void AddTx(CWallet& wallet)
51+
{
52+
bilingual_str error;
53+
CTxDestination dest;
54+
wallet.GetNewDestination(OutputType::BECH32, "", dest, error);
55+
56+
CMutableTransaction mtx;
57+
mtx.vout.push_back({COIN, GetScriptForDestination(dest)});
58+
mtx.vin.push_back(CTxIn());
59+
60+
wallet.AddToWallet(MakeTransactionRef(mtx), TxStateInactive{});
61+
}
62+
4963
static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
5064
{
5165
const auto test_setup = MakeNoLogFileContext<TestingSetup>();
@@ -63,7 +77,7 @@ static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
6377

6478
// Generate a bunch of transactions and addresses to put into the wallet
6579
for (int i = 0; i < 5000; ++i) {
66-
generatetoaddress(test_setup->m_node, getnewaddress(*wallet));
80+
AddTx(*wallet);
6781
}
6882

6983
// reload the wallet for the actual benchmark

0 commit comments

Comments
 (0)