5 #ifndef BITCOIN_WALLET_SQLITE_H 6 #define BITCOIN_WALLET_SQLITE_H 30 explicit SQLiteCursor(std::vector<std::byte> start_range, std::vector<std::byte> end_range)
67 void Close()
override;
109 void Open() override;
112 void Close() override;
119 bool Rewrite(
const char* skip =
nullptr)
override;
123 bool Backup(
const std::string& dest)
const override;
140 std::string
Format()
override {
return "sqlite"; }
143 std::unique_ptr<DatabaseBatch>
MakeBatch(
bool flush_on_close =
true)
override;
154 #endif // BITCOIN_WALLET_SQLITE_H
void Cleanup() noexcept EXCLUSIVE_LOCKS_REQUIRED(!g_sqlite_mutex)
static Mutex g_sqlite_mutex
This mutex protects SQLite initialization and shutdown.
std::unique_ptr< SQLiteDatabase > MakeSQLiteDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
void IncrementUpdateCounter() override
bool TxnCommit() override
const std::string m_file_path
void SetupSQLStatements()
SQLiteDatabase & m_database
bool HasKey(DataStream &&key) override
std::string SQLiteDatabaseVersion()
sqlite3_stmt * m_overwrite_stmt
std::string Format() override
sqlite3_stmt * m_insert_stmt
std::atomic< unsigned int > nUpdateCounter
std::unique_ptr< DatabaseCursor > GetNewCursor() override
RAII class that provides access to a WalletDatabase.
Filesystem operations and types.
bool Verify(bilingual_str &error)
static int g_sqlite_count GUARDED_BY(g_sqlite_mutex)
bool Rewrite(const char *skip=nullptr) override
Rewrite the entire database on disk.
std::vector< std::byte > m_prefix_range_end
Double ended buffer combining vector and stream-like interfaces.
void Open() override
Open the database if it is not already opened.
bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true) override
std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(Span< const std::byte > prefix) override
bool EraseKey(DataStream &&key) override
std::vector< std::byte > m_prefix_range_start
std::unique_ptr< DatabaseBatch > MakeBatch(bool flush_on_close=true) override
Make a SQLiteBatch connected to this database.
SQLiteBatch(SQLiteDatabase &database)
Status Next(DataStream &key, DataStream &value) override
RAII class that provides a database cursor.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
const std::string m_dir_path
std::string Filename() override
Return path to main database file for logs and error messages.
sqlite3_stmt * m_cursor_stmt
bool ReadKey(DataStream &&key, DataStream &value) override
bool error(const char *fmt, const Args &... args)
SQLiteCursor(std::vector< std::byte > start_range, std::vector< std::byte > end_range)
bool ExecStatement(sqlite3_stmt *stmt, Span< const std::byte > blob)
void AddRef() override
Indicate the a new database user has began using the database.
bool ErasePrefix(Span< const std::byte > prefix) override
An instance of this class represents one SQLite3 database.
RAII class that provides access to a WalletDatabase.
sqlite3_stmt * m_delete_stmt
void RemoveRef() override
Indicate that database user has stopped using the database and that it could be flushed or closed...
sqlite3_stmt * m_delete_prefix_stmt
void Flush() override
No-ops.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
bool Backup(const std::string &dest) const override
Back up the entire database to a file.
void ReloadDbEnv() override
An instance of this class represents one database.
sqlite3_stmt * m_read_stmt
void Close() override
Close the database.
bool PeriodicFlush() override