wallet, bench: Remove unused database options from WalletBenchLoading

This commit is contained in:
Andrew Chow 2023-05-03 10:38:27 -04:00
parent 80ace042d8
commit 33e2b82a4f

View file

@ -18,18 +18,16 @@
using wallet::CWallet; using wallet::CWallet;
using wallet::CreateMockableWalletDatabase; using wallet::CreateMockableWalletDatabase;
using wallet::DatabaseFormat;
using wallet::DatabaseOptions;
using wallet::TxStateInactive; using wallet::TxStateInactive;
using wallet::WALLET_FLAG_DESCRIPTORS; using wallet::WALLET_FLAG_DESCRIPTORS;
using wallet::WalletContext; using wallet::WalletContext;
using wallet::WalletDatabase; using wallet::WalletDatabase;
static std::shared_ptr<CWallet> BenchLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context, DatabaseOptions& options) static std::shared_ptr<CWallet> BenchLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context, uint64_t create_flags)
{ {
bilingual_str error; bilingual_str error;
std::vector<bilingual_str> warnings; std::vector<bilingual_str> warnings;
auto wallet = CWallet::Create(context, "", std::move(database), options.create_flags, error, warnings); auto wallet = CWallet::Create(context, "", std::move(database), create_flags, error, warnings);
NotifyWalletLoaded(context, wallet); NotifyWalletLoaded(context, wallet);
if (context.chain) { if (context.chain) {
wallet->postInitProcess(); wallet->postInitProcess();
@ -56,7 +54,6 @@ static void AddTx(CWallet& wallet)
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>();
test_setup->m_args.ForceSetArg("-unsafesqlitesync", "1");
WalletContext context; WalletContext context;
context.args = &test_setup->m_args; context.args = &test_setup->m_args;
@ -64,15 +61,12 @@ static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
// Setup the wallet // Setup the wallet
// Loading the wallet will also create it // Loading the wallet will also create it
DatabaseOptions options; uint64_t create_flags = 0;
if (legacy_wallet) { if (!legacy_wallet) {
options.require_format = DatabaseFormat::BERKELEY; create_flags = WALLET_FLAG_DESCRIPTORS;
} else {
options.create_flags = WALLET_FLAG_DESCRIPTORS;
options.require_format = DatabaseFormat::SQLITE;
} }
auto database = CreateMockableWalletDatabase(); auto database = CreateMockableWalletDatabase();
auto wallet = BenchLoadWallet(std::move(database), context, options); auto wallet = BenchLoadWallet(std::move(database), context, create_flags);
// 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 < 1000; ++i) { for (int i = 0; i < 1000; ++i) {
@ -85,7 +79,7 @@ static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
BenchUnloadWallet(std::move(wallet)); BenchUnloadWallet(std::move(wallet));
bench.epochs(5).run([&] { bench.epochs(5).run([&] {
wallet = BenchLoadWallet(std::move(database), context, options); wallet = BenchLoadWallet(std::move(database), context, create_flags);
// Cleanup // Cleanup
database = DuplicateMockDatabase(wallet->GetDatabase()); database = DuplicateMockDatabase(wallet->GetDatabase());