mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
bench: Add transactions directly instead of mining blocks
This commit is contained in:
parent
d94244c4bf
commit
f85b54ed27
1 changed files with 15 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue