aboutsummaryrefslogtreecommitdiff
path: root/src/bench
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2022-04-20 13:25:06 -0400
committerAndrew Chow <achow101-github@achow101.com>2022-04-20 13:55:56 -0400
commitf85b54ed27bd6eddb1e7035db02d542575b3ab24 (patch)
treec8bbcb926077017524b58243a53abe515948caf4 /src/bench
parentd94244c4bf37365272a16eb2ce6517605b4c8a47 (diff)
downloadbitcoin-f85b54ed27bd6eddb1e7035db02d542575b3ab24.tar.xz
bench: Add transactions directly instead of mining blocks
Diffstat (limited to 'src/bench')
-rw-r--r--src/bench/wallet_loading.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/bench/wallet_loading.cpp b/src/bench/wallet_loading.cpp
index 5096895ed8..1a3ae65111 100644
--- a/src/bench/wallet_loading.cpp
+++ b/src/bench/wallet_loading.cpp
@@ -21,6 +21,7 @@ using wallet::DatabaseOptions;
using wallet::DatabaseStatus;
using wallet::ISMINE_SPENDABLE;
using wallet::MakeWalletDatabase;
+using wallet::TxStateInactive;
using wallet::WALLET_FLAG_DESCRIPTORS;
using wallet::WalletContext;
@@ -46,6 +47,19 @@ static void BenchUnloadWallet(std::shared_ptr<CWallet>&& wallet)
UnloadWallet(std::move(wallet));
}
+static void AddTx(CWallet& wallet)
+{
+ bilingual_str error;
+ CTxDestination dest;
+ wallet.GetNewDestination(OutputType::BECH32, "", dest, error);
+
+ CMutableTransaction mtx;
+ mtx.vout.push_back({COIN, GetScriptForDestination(dest)});
+ mtx.vin.push_back(CTxIn());
+
+ wallet.AddToWallet(MakeTransactionRef(mtx), TxStateInactive{});
+}
+
static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
{
const auto test_setup = MakeNoLogFileContext<TestingSetup>();
@@ -63,7 +77,7 @@ static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
// Generate a bunch of transactions and addresses to put into the wallet
for (int i = 0; i < 5000; ++i) {
- generatetoaddress(test_setup->m_node, getnewaddress(*wallet));
+ AddTx(*wallet);
}
// reload the wallet for the actual benchmark