mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
wallet: Introduce DatabaseCursor RAII class for managing cursor
Instead of having DatabaseBatch deal with opening and closing database cursors, have a separate RAII class that deals with those. For now, DatabaseBatch manages DatabaseCursor, but this will change later.
This commit is contained in:
@@ -867,6 +867,12 @@ BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
|
||||
TestUnloadWallet(std::move(wallet));
|
||||
}
|
||||
|
||||
class FailCursor : public DatabaseCursor
|
||||
{
|
||||
public:
|
||||
bool Next(CDataStream& key, CDataStream& value, bool& complete) override { return false; }
|
||||
};
|
||||
|
||||
/** RAII class that provides access to a FailDatabase. Which fails if needed. */
|
||||
class FailBatch : public DatabaseBatch
|
||||
{
|
||||
@@ -882,9 +888,7 @@ public:
|
||||
void Flush() override {}
|
||||
void Close() override {}
|
||||
|
||||
bool StartCursor() override { return true; }
|
||||
bool ReadAtCursor(CDataStream& ssKey, CDataStream& ssValue, bool& complete) override { return false; }
|
||||
void CloseCursor() override {}
|
||||
std::unique_ptr<DatabaseCursor> GetNewCursor() override { return std::make_unique<FailCursor>(); }
|
||||
bool TxnBegin() override { return false; }
|
||||
bool TxnCommit() override { return false; }
|
||||
bool TxnAbort() override { return false; }
|
||||
|
||||
Reference in New Issue
Block a user