6#ifndef BITCOIN_WALLET_DB_H
7#define BITCOIN_WALLET_DB_H
67 template <
typename K,
typename T>
68 bool Read(
const K& key, T& value)
75 if (!
ReadKey(std::move(ssKey), ssValue))
return false;
79 }
catch (
const std::exception&) {
84 template <
typename K,
typename T>
85 bool Write(
const K& key,
const T& value,
bool fOverwrite =
true)
95 return WriteKey(std::move(ssKey), std::move(ssValue), fOverwrite);
108 template <
typename K>
115 return HasKey(std::move(ssKey));
144 virtual bool Rewrite(
const char* pszSkip=
nullptr) = 0;
148 virtual bool Backup(
const std::string& strDest)
const = 0;
198std::vector<std::pair<fs::path, std::string>>
ListDatabases(
const fs::path& path);
Double ended buffer combining vector and stream-like interfaces.
void reserve(size_type n)
RAII class that provides access to a WalletDatabase.
bool Write(const K &key, const T &value, bool fOverwrite=true)
virtual bool TxnAbort()=0
DatabaseBatch(const DatabaseBatch &)=delete
virtual ~DatabaseBatch()=default
bool Read(const K &key, T &value)
virtual bool EraseKey(DataStream &&key)=0
virtual bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true)=0
virtual bool TxnBegin()=0
DatabaseBatch & operator=(const DatabaseBatch &)=delete
virtual std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(std::span< const std::byte > prefix)=0
virtual bool ReadKey(DataStream &&key, DataStream &value)=0
bool Exists(const K &key)
virtual std::unique_ptr< DatabaseCursor > GetNewCursor()=0
virtual bool HasKey(DataStream &&key)=0
virtual bool HasActiveTxn()=0
virtual bool TxnCommit()=0
virtual bool ErasePrefix(std::span< const std::byte > prefix)=0
DatabaseCursor & operator=(const DatabaseCursor &)=delete
virtual ~DatabaseCursor()=default
DatabaseCursor(const DatabaseCursor &)=delete
virtual Status Next(DataStream &key, DataStream &value)
An instance of this class represents one database.
virtual std::string Format()=0
virtual ~WalletDatabase()=default
virtual void Open()=0
Open the database if it is not already opened.
virtual bool Rewrite(const char *pszSkip=nullptr)=0
Rewrite the entire database on disk, with the exception of key pszSkip if non-zero.
virtual void Close()=0
Flush to the database file and close the database.
virtual bool Backup(const std::string &strDest) const =0
Back up the entire database to a file.
virtual std::unique_ptr< DatabaseBatch > MakeBatch()=0
Make a DatabaseBatch connected to this database.
std::atomic< int > m_refcount
Counts the number of active database users to be sure that the database is not closed while someone i...
WalletDatabase()=default
Create dummy DB handle.
virtual std::string Filename()=0
Return path to main database file for logs and error messages.
@ FAIL
Just act as if the signature was invalid.
void ReadDatabaseArgs(const ArgsManager &args, DatabaseOptions &options)
std::unique_ptr< WalletDatabase > MakeDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
bool operator<(BytePrefix a, std::span< const std::byte > b)
fs::path SQLiteDataFile(const fs::path &path)
bool IsBDBFile(const fs::path &path)
fs::path BDBDataFile(const fs::path &wallet_path)
bool IsSQLiteFile(const fs::path &path)
std::vector< std::pair< fs::path, std::string > > ListDatabases(const fs::path &wallet_dir)
Recursively list database paths in directory.
@ FAILED_INVALID_BACKUP_FILE
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
std::span< const std::byte > prefix
bool verify
Check data integrity on load.
bool use_shared_memory
Let other processes access the database.
SecureString create_passphrase
std::optional< DatabaseFormat > require_format
bool use_unsafe_sync
Disable file sync for faster performance.
int64_t max_log_mb
Max log size to allow before consolidating.