5 #ifndef BITCOIN_WALLET_SQLITE_H 6 #define BITCOIN_WALLET_SQLITE_H 32 explicit SQLiteCursor(std::vector<std::byte> start_range, std::vector<std::byte> end_range)
55 std::unique_ptr<SQliteExecHandler>
m_exec_handler{std::make_unique<SQliteExecHandler>()};
76 bool ExecStatement(sqlite3_stmt* stmt, std::span<const std::byte> blob);
90 void Close()
override;
137 void Open() override;
140 void Close() override;
147 bool Backup(const
std::
string& dest) const override;
151 std::vector<fs::path>
Files()
override 153 std::vector<fs::path> files;
158 std::string
Format()
override {
return "sqlite"; }
161 std::unique_ptr<DatabaseBatch>
MakeBatch()
override;
175 #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 SetExecHandler(std::unique_ptr< SQliteExecHandler > &&handler)
bool TxnCommit() override
const std::string m_file_path
void SetupSQLStatements()
bool m_txn
Whether this batch has started a database transaction and whether it owns SQLiteDatabase::m_write_sem...
SQLiteDatabase & m_database
bool HasKey(DataStream &&key) override
std::unique_ptr< DatabaseBatch > MakeBatch() override
Make a SQLiteBatch connected to this database.
std::string SQLiteDatabaseVersion()
sqlite3_stmt * m_overwrite_stmt
std::string Format() override
sqlite3_stmt * m_insert_stmt
bool(* handler)(const std::any &context, HTTPRequest *req, const std::string &strReq)
std::unique_ptr< DatabaseCursor > GetNewCursor() override
RAII class that provides access to a WalletDatabase.
virtual int Exec(SQLiteDatabase &database, const std::string &statement)
std::unique_ptr< SQliteExecHandler > m_exec_handler
bool Verify(bilingual_str &error)
static int g_sqlite_count GUARDED_BY(g_sqlite_mutex)
std::binary_semaphore m_write_semaphore
bool ErasePrefix(std::span< const std::byte > prefix) override
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 HasActiveTxn() override
bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true) override
bool Rewrite() override
Rewrite the entire database on disk.
bool HasActiveTxn()
Return true if there is an on-going txn in this connection.
bool EraseKey(DataStream &&key) override
bool ExecStatement(sqlite3_stmt *stmt, std::span< const std::byte > blob)
std::vector< std::byte > m_prefix_range_start
SQLiteBatch(SQLiteDatabase &database)
Status Next(DataStream &key, DataStream &value) override
RAII class that provides a database cursor.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(std::span< const std::byte > prefix) override
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
SQLiteCursor(std::vector< std::byte > start_range, std::vector< std::byte > end_range)
Class responsible for executing SQL statements in SQLite databases.
virtual ~SQliteExecHandler()=default
An instance of this class represents one SQLite3 database.
RAII class that provides access to a WalletDatabase.
const fs::path m_dir_path
sqlite3_stmt * m_delete_stmt
static path PathFromString(const std::string &string)
Convert byte string to path object.
sqlite3_stmt * m_delete_prefix_stmt
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.
An instance of this class represents one database.
sqlite3_stmt * m_read_stmt
void Close() override
Close the database.
std::vector< fs::path > Files() override
Return paths to all database created files.