mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-13 03:30:42 +02:00
bench: Add transactions directly instead of mining blocks
This commit is contained in:
parent
d94244c4bf
commit
f85b54ed27
@ -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…
Reference in New Issue
Block a user