0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-09 10:43:19 -05:00

bench: Add transactions directly instead of mining blocks

This commit is contained in:
Andrew Chow 2022-04-20 13:25:06 -04:00
parent d94244c4bf
commit f85b54ed27

View file

@ -21,6 +21,7 @@ using wallet::DatabaseOptions;
using wallet::DatabaseStatus; using wallet::DatabaseStatus;
using wallet::ISMINE_SPENDABLE; using wallet::ISMINE_SPENDABLE;
using wallet::MakeWalletDatabase; using wallet::MakeWalletDatabase;
using wallet::TxStateInactive;
using wallet::WALLET_FLAG_DESCRIPTORS; using wallet::WALLET_FLAG_DESCRIPTORS;
using wallet::WalletContext; using wallet::WalletContext;
@ -46,6 +47,19 @@ static void BenchUnloadWallet(std::shared_ptr<CWallet>&& wallet)
UnloadWallet(std::move(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) static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
{ {
const auto test_setup = MakeNoLogFileContext<TestingSetup>(); 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 // Generate a bunch of transactions and addresses to put into the wallet
for (int i = 0; i < 5000; ++i) { for (int i = 0; i < 5000; ++i) {
generatetoaddress(test_setup->m_node, getnewaddress(*wallet)); AddTx(*wallet);
} }
// reload the wallet for the actual benchmark // reload the wallet for the actual benchmark