aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/bdb.h
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2022-04-11 15:14:24 -0400
committerAndrew Chow <github@achow101.com>2022-12-14 12:41:41 -0500
commit7a198bba0a1d0a0f0fd4ca947955cb52b84bdd4b (patch)
treeac500d26ed18aeb2265c814aac88158c858a9e8f /src/wallet/bdb.h
parent69efbc011bb74fcd8dd9ed2a8a5d31bc9e323c10 (diff)
downloadbitcoin-7a198bba0a1d0a0f0fd4ca947955cb52b84bdd4b.tar.xz
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.
Diffstat (limited to 'src/wallet/bdb.h')
-rw-r--r--src/wallet/bdb.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h
index 35cc823876..0ee94fa2bc 100644
--- a/src/wallet/bdb.h
+++ b/src/wallet/bdb.h
@@ -185,6 +185,18 @@ public:
operator Dbt*();
};
+class BerkeleyCursor : public DatabaseCursor
+{
+private:
+ Dbc* m_cursor;
+
+public:
+ explicit BerkeleyCursor(BerkeleyDatabase& database);
+ ~BerkeleyCursor() override;
+
+ bool Next(CDataStream& key, CDataStream& value, bool& complete) override;
+};
+
/** RAII class that provides access to a Berkeley database */
class BerkeleyBatch : public DatabaseBatch
{
@@ -198,7 +210,6 @@ protected:
Db* pdb;
std::string strFile;
DbTxn* activeTxn;
- Dbc* m_cursor;
bool fReadOnly;
bool fFlushOnClose;
BerkeleyEnvironment *env;
@@ -214,9 +225,7 @@ public:
void Flush() override;
void Close() override;
- bool StartCursor() override;
- bool ReadAtCursor(CDataStream& ssKey, CDataStream& ssValue, bool& complete) override;
- void CloseCursor() override;
+ std::unique_ptr<DatabaseCursor> GetNewCursor() override;
bool TxnBegin() override;
bool TxnCommit() override;
bool TxnAbort() override;