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)
53 std::unique_ptr<SQliteExecHandler>
m_exec_handler{std::make_unique<SQliteExecHandler>()};
91 void Close()
override;
138 void Open() override;
141 void Close() override;
148 bool Rewrite(
const char* skip =
nullptr)
override;
152 bool Backup(
const std::string& dest)
const override;
169 std::string
Format()
override {
return "sqlite"; }
172 std::unique_ptr<DatabaseBatch>
MakeBatch(
bool flush_on_close =
true)
override;
An implementation of a semaphore.
Double ended buffer combining vector and stream-like interfaces.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
RAII class that provides access to a WalletDatabase.
RAII class that provides access to a WalletDatabase.
bool ReadKey(DataStream &&key, DataStream &value) override
bool TxnCommit() override
SQLiteBatch(SQLiteDatabase &database)
std::unique_ptr< SQliteExecHandler > m_exec_handler
bool HasKey(DataStream &&key) override
bool m_txn
Whether this batch has started a database transaction and whether it owns SQLiteDatabase::m_write_sem...
std::unique_ptr< DatabaseCursor > GetNewCursor() override
bool ErasePrefix(Span< const std::byte > prefix) override
bool EraseKey(DataStream &&key) override
sqlite3_stmt * m_delete_stmt
sqlite3_stmt * m_read_stmt
sqlite3_stmt * m_overwrite_stmt
bool ExecStatement(sqlite3_stmt *stmt, Span< const std::byte > blob)
std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(Span< const std::byte > prefix) override
void SetExecHandler(std::unique_ptr< SQliteExecHandler > &&handler)
sqlite3_stmt * m_delete_prefix_stmt
void SetupSQLStatements()
sqlite3_stmt * m_insert_stmt
bool HasActiveTxn() override
SQLiteDatabase & m_database
bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true) override
RAII class that provides a database cursor.
std::vector< std::byte > m_prefix_range_start
Status Next(DataStream &key, DataStream &value) override
sqlite3_stmt * m_cursor_stmt
SQLiteCursor(std::vector< std::byte > start_range, std::vector< std::byte > end_range)
std::vector< std::byte > m_prefix_range_end
An instance of this class represents one SQLite3 database.
static Mutex g_sqlite_mutex
This mutex protects SQLite initialization and shutdown.
void Flush() override
No-ops.
std::string Format() override
CSemaphore m_write_semaphore
static int g_sqlite_count GUARDED_BY(g_sqlite_mutex)
bool PeriodicFlush() override
void IncrementUpdateCounter() override
void Open() override
Open the database if it is not already opened.
std::string Filename() override
Return path to main database file for logs and error messages.
bool Rewrite(const char *skip=nullptr) override
Rewrite the entire database on disk.
void Cleanup() noexcept EXCLUSIVE_LOCKS_REQUIRED(!g_sqlite_mutex)
void Close() override
Close the database.
void ReloadDbEnv() override
bool Backup(const std::string &dest) const override
Back up the entire database to a file.
const std::string m_dir_path
void AddRef() override
Indicate the a new database user has began using the database.
const std::string m_file_path
std::unique_ptr< DatabaseBatch > MakeBatch(bool flush_on_close=true) override
Make a SQLiteBatch connected to this database.
bool Verify(bilingual_str &error)
void RemoveRef() override
Indicate that database user has stopped using the database and that it could be flushed or closed.
bool HasActiveTxn()
Return true if there is an on-going txn in this connection.
Class responsible for executing SQL statements in SQLite databases.
virtual int Exec(SQLiteDatabase &database, const std::string &statement)
virtual ~SQliteExecHandler()=default
An instance of this class represents one database.
std::atomic< unsigned int > nUpdateCounter
Filesystem operations and types.
std::unique_ptr< SQLiteDatabase > MakeSQLiteDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
std::string SQLiteDatabaseVersion()
bool(* handler)(const std::any &context, HTTPRequest *req, const std::string &strReq)
#define EXCLUSIVE_LOCKS_REQUIRED(...)