6 #ifndef BITCOIN_WALLET_DB_H 7 #define BITCOIN_WALLET_DB_H 60 virtual void Flush() = 0;
61 virtual void Close() = 0;
63 template <
typename K,
typename T>
64 bool Read(
const K& key, T& value)
71 if (!
ReadKey(std::move(ssKey), ssValue))
return false;
75 }
catch (
const std::exception&) {
80 template <
typename K,
typename T>
81 bool Write(
const K& key,
const T& value,
bool fOverwrite =
true)
91 return WriteKey(std::move(ssKey), std::move(ssValue), fOverwrite);
104 template <
typename K>
111 return HasKey(std::move(ssKey));
115 virtual std::unique_ptr<DatabaseCursor>
GetNewCursor() = 0;
132 virtual void Open() = 0;
137 virtual void AddRef() = 0;
143 virtual bool Rewrite(
const char* pszSkip=
nullptr) = 0;
147 virtual bool Backup(
const std::string& strDest)
const = 0;
151 virtual void Flush() = 0;
155 virtual void Close() = 0;
167 virtual std::string
Format() = 0;
175 virtual std::unique_ptr<DatabaseBatch>
MakeBatch(
bool flush_on_close =
true) = 0;
223 #endif // BITCOIN_WALLET_DB_H std::unique_ptr< WalletDatabase > MakeDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
std::optional< DatabaseFormat > require_format
void ReadDatabaseArgs(const ArgsManager &args, DatabaseOptions &options)
virtual std::unique_ptr< DatabaseCursor > GetNewCursor()=0
void reserve(size_type n)
virtual bool HasKey(DataStream &&key)=0
virtual bool Backup(const std::string &strDest) const =0
Back up the entire database to a file.
virtual bool TxnAbort()=0
virtual void Flush()=0
Make sure all changes are flushed to database file.
bool use_unsafe_sync
Disable file sync for faster performance.
virtual bool ErasePrefix(Span< const std::byte > prefix)=0
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
virtual void Open()=0
Open the database if it is not already opened.
virtual std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(Span< const std::byte > prefix)=0
WalletDatabase()
Create dummy DB handle.
virtual void Close()=0
Flush to the database file and close the database.
bool Write(const K &key, const T &value, bool fOverwrite=true)
std::atomic< unsigned int > nUpdateCounter
virtual bool Rewrite(const char *pszSkip=nullptr)=0
Rewrite the entire database on disk, with the exception of key pszSkip if non-zero.
RAII class that provides access to a WalletDatabase.
fs::path SQLiteDataFile(const fs::path &path)
virtual bool TxnBegin()=0
virtual void RemoveRef()=0
Indicate that database user has stopped using the database and that it could be flushed or closed...
int64_t nLastWalletUpdate
std::atomic< int > m_refcount
Counts the number of active database users to be sure that the database is not closed while someone i...
DatabaseCursor & operator=(const DatabaseCursor &)=delete
bool Read(const K &key, T &value)
SecureString create_passphrase
bool IsBDBFile(const fs::path &path)
bool Exists(const K &key)
virtual bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true)=0
Double ended buffer combining vector and stream-like interfaces.
unsigned int nLastFlushed
virtual std::string Filename()=0
Return path to main database file for logs and error messages.
virtual void ReloadDbEnv()=0
virtual void IncrementUpdateCounter()=0
virtual void AddRef()=0
Indicate the a new database user has began using the database.
virtual bool ReadKey(DataStream &&key, DataStream &value)=0
virtual ~WalletDatabase()
virtual bool EraseKey(DataStream &&key)=0
virtual bool TxnCommit()=0
virtual bool PeriodicFlush()=0
bool use_shared_memory
Let other processes access the database.
virtual ~DatabaseCursor()
virtual Status Next(DataStream &key, DataStream &value)
int64_t max_log_mb
Max log size to allow before consolidating.
bool error(const char *fmt, const Args &... args)
fs::path BDBDataFile(const fs::path &wallet_path)
bool IsSQLiteFile(const fs::path &path)
virtual std::unique_ptr< DatabaseBatch > MakeBatch(bool flush_on_close=true)=0
Make a DatabaseBatch connected to this database.
void SplitWalletPath(const fs::path &wallet_path, fs::path &env_directory, std::string &database_filename)
std::vector< fs::path > ListDatabases(const fs::path &wallet_dir)
Recursively list database paths in directory.
virtual std::string Format()=0
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
bool verify
Check data integrity on load.
static const int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
DatabaseBatch & operator=(const DatabaseBatch &)=delete
An instance of this class represents one database.