mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
wallet: Have cursor users use DatabaseCursor directly
Instead of having the DatabaseBatch manage the cursor, having the consumer handle it directly
This commit is contained in:
@@ -50,7 +50,7 @@ std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database,
|
||||
|
||||
// Get a cursor to the original database
|
||||
auto batch = database.MakeBatch();
|
||||
batch->StartCursor();
|
||||
std::unique_ptr<wallet::DatabaseCursor> cursor = batch->GetNewCursor();
|
||||
|
||||
// Get a batch for the new database
|
||||
auto new_batch = new_database->MakeBatch();
|
||||
@@ -60,7 +60,7 @@ std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database,
|
||||
CDataStream key(SER_DISK, CLIENT_VERSION);
|
||||
CDataStream value(SER_DISK, CLIENT_VERSION);
|
||||
bool complete;
|
||||
batch->ReadAtCursor(key, value, complete);
|
||||
cursor->Next(key, value, complete);
|
||||
if (complete) break;
|
||||
new_batch->Write(key, value);
|
||||
}
|
||||
|
||||
@@ -54,12 +54,14 @@ BOOST_FIXTURE_TEST_CASE(wallet_load_unknown_descriptor, TestingSetup)
|
||||
bool HasAnyRecordOfType(WalletDatabase& db, const std::string& key)
|
||||
{
|
||||
std::unique_ptr<DatabaseBatch> batch = db.MakeBatch(false);
|
||||
BOOST_CHECK(batch->StartCursor());
|
||||
BOOST_CHECK(batch);
|
||||
std::unique_ptr<DatabaseCursor> cursor = batch->GetNewCursor();
|
||||
BOOST_CHECK(cursor);
|
||||
while (true) {
|
||||
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
|
||||
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||
bool complete;
|
||||
BOOST_CHECK(batch->ReadAtCursor(ssKey, ssValue, complete));
|
||||
BOOST_CHECK(cursor->Next(ssKey, ssValue, complete));
|
||||
if (complete) break;
|
||||
std::string type;
|
||||
ssKey >> type;
|
||||
|
||||
Reference in New Issue
Block a user