Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bench/wallet_migration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static void WalletMigration(benchmark::Bench& bench)
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase());
wallet->chainStateFlushed(ChainstateRole::NORMAL, CBlockLocator{});
LegacyDataSPKM* legacy_spkm = wallet->GetOrCreateLegacyDataSPKM();
WalletBatch batch{wallet->GetDatabase()};

// Add watch-only addresses
std::vector<CScript> scripts_watch_only;
Expand All @@ -42,6 +43,7 @@ static void WalletMigration(benchmark::Bench& bench)
const CScript& script = scripts_watch_only.emplace_back(GetScriptForDestination(dest));
assert(legacy_spkm->LoadWatchOnly(script));
assert(wallet->SetAddressBook(dest, strprintf("watch_%d", w), /*purpose=*/std::nullopt));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context on my comment in #32277 (comment), SetAddressBook() includes a write to the database, and so does AddToWallet(tx)

This is the reason why some records were persisted, but none that were strictly "legacy" records as mentioned in #32277 (comment).

(@furszy)

batch.WriteWatchOnly(script, CKeyMetadata());
}

// Generate transactions and local addresses
Expand All @@ -58,6 +60,7 @@ static void WalletMigration(benchmark::Bench& bench)
mtx.vout.emplace_back(COIN, scripts_watch_only.at(j % NUM_WATCH_ONLY_ADDR));
mtx.vin.resize(2);
wallet->AddToWallet(MakeTransactionRef(mtx), TxStateInactive{}, /*update_wtx=*/nullptr, /*fFlushOnClose=*/false, /*rescanning_old_block=*/true);
batch.WriteKey(pubkey, key.GetPrivKey(), CKeyMetadata());
}

bench.epochs(/*numEpochs=*/1).run([&context, &wallet] {
Expand Down