mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 18:22:57 +02:00
refactor: move DuplicateMockDatabase to wallet/test/util.h
This commit is contained in:
@@ -52,30 +52,6 @@ static void AddTx(CWallet& wallet)
|
||||
wallet.AddToWallet(MakeTransactionRef(mtx), TxStateInactive{});
|
||||
}
|
||||
|
||||
static std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database, DatabaseOptions& options)
|
||||
{
|
||||
auto new_database = CreateMockWalletDatabase(options);
|
||||
|
||||
// Get a cursor to the original database
|
||||
auto batch = database.MakeBatch();
|
||||
batch->StartCursor();
|
||||
|
||||
// Get a batch for the new database
|
||||
auto new_batch = new_database->MakeBatch();
|
||||
|
||||
// Read all records from the original database and write them to the new one
|
||||
while (true) {
|
||||
CDataStream key(SER_DISK, CLIENT_VERSION);
|
||||
CDataStream value(SER_DISK, CLIENT_VERSION);
|
||||
bool complete;
|
||||
batch->ReadAtCursor(key, value, complete);
|
||||
if (complete) break;
|
||||
new_batch->Write(key, value);
|
||||
}
|
||||
|
||||
return new_database;
|
||||
}
|
||||
|
||||
static void WalletLoading(benchmark::Bench& bench, bool legacy_wallet)
|
||||
{
|
||||
const auto test_setup = MakeNoLogFileContext<TestingSetup>();
|
||||
|
||||
Reference in New Issue
Block a user