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;
137 void Open() override;
140 void Close() override;
147 bool Rewrite(
const char* skip =
nullptr)
override;
151 bool Backup(
const std::string& dest)
const override;
168 std::string
Format()
override {
return "sqlite"; }
171 std::unique_ptr<DatabaseBatch>
MakeBatch(
bool flush_on_close =
true)
override;
185 #endif // BITCOIN_WALLET_SQLITE_H
An implementation of a semaphore.
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
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::string SQLiteDatabaseVersion()
sqlite3_stmt * m_overwrite_stmt
std::string Format() override
sqlite3_stmt * m_insert_stmt
std::atomic< unsigned int > nUpdateCounter
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.
Filesystem operations and types.
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)
bool Rewrite(const char *skip=nullptr) override
Rewrite the entire database on disk.
CSemaphore m_write_semaphore
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 HasActiveTxn()
Return true if there is an on-going txn in this connection.
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
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
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