 |
Bitcoin Core
21.99.0
P2P Digital Currency
|
Go to the documentation of this file.
6 #ifndef BITCOIN_WALLET_DB_H
7 #define BITCOIN_WALLET_DB_H
21 void SplitWalletPath(
const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename);
39 virtual void Flush() = 0;
40 virtual void Close() = 0;
42 template <
typename K,
typename T>
43 bool Read(
const K& key, T& value)
50 if (!
ReadKey(std::move(ssKey), ssValue))
return false;
54 }
catch (
const std::exception&) {
59 template <
typename K,
typename T>
60 bool Write(
const K& key,
const T& value,
bool fOverwrite =
true)
70 return WriteKey(std::move(ssKey), std::move(ssValue), fOverwrite);
90 return HasKey(std::move(ssKey));
111 virtual void Open() = 0;
116 virtual void AddRef() = 0;
122 virtual bool Rewrite(
const char* pszSkip=
nullptr) = 0;
126 virtual bool Backup(
const std::string& strDest)
const = 0;
130 virtual void Flush() = 0;
134 virtual void Close() = 0;
146 virtual std::string
Format() = 0;
154 virtual std::unique_ptr<DatabaseBatch>
MakeBatch(
bool flush_on_close =
true) = 0;
186 bool Rewrite(
const char* pszSkip=
nullptr)
override {
return true; }
187 bool Backup(
const std::string& strDest)
const override {
return true; }
193 std::string
Filename()
override {
return "dummy"; }
194 std::string
Format()
override {
return "dummy"; }
195 std::unique_ptr<DatabaseBatch>
MakeBatch(
bool flush_on_close =
true)
override {
return std::make_unique<DummyBatch>(); }
235 #endif // BITCOIN_WALLET_DB_H
std::string Format() override
virtual void CloseCursor()=0
virtual bool TxnCommit()=0
void CloseCursor() override
virtual void IncrementUpdateCounter()=0
virtual void Open()=0
Open the database if it is not already opened.
bool ReadKey(CDataStream &&key, CDataStream &value) override
virtual bool TxnBegin()=0
void ReloadDbEnv() override
fs::path BDBDataFile(const fs::path &path)
SecureString create_passphrase
std::vector< fs::path > ListDatabases(const fs::path &path)
Recursively list database paths in directory.
void SplitWalletPath(const fs::path &wallet_path, fs::path &env_directory, std::string &database_filename)
virtual ~WalletDatabase()
bool Read(const K &key, T &value)
virtual bool WriteKey(CDataStream &&key, CDataStream &&value, bool overwrite=true)=0
RAII class that provides access to a DummyDatabase.
void IncrementUpdateCounter() override
virtual void Close()=0
Flush to the database file and close the database.
An instance of this class represents one database.
fs::path SQLiteDataFile(const fs::path &path)
virtual bool Backup(const std::string &strDest) const =0
Back up the entire database to a file.
A dummy WalletDatabase that does nothing and never fails.
virtual bool EraseKey(CDataStream &&key)=0
bool EraseKey(CDataStream &&key) override
bool Write(const K &key, const T &value, bool fOverwrite=true)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
virtual bool TxnAbort()=0
std::atomic< unsigned int > nUpdateCounter
int64_t nLastWalletUpdate
void Close() override
Flush to the database file and close the database.
virtual void RemoveRef()=0
Indicate that database user has stopped using the database and that it could be flushed or closed.
bool Exists(const K &key)
bool IsBDBFile(const fs::path &path)
unsigned int nLastFlushed
bool HasKey(CDataStream &&key) override
RAII class that provides access to a WalletDatabase.
bool ReadAtCursor(CDataStream &ssKey, CDataStream &ssValue, bool &complete) override
std::unique_ptr< DatabaseBatch > MakeBatch(bool flush_on_close=true) override
Make a DatabaseBatch connected to this database.
void AddRef() override
Indicate the a new database user has began using the database.
virtual void ReloadDbEnv()=0
virtual std::unique_ptr< DatabaseBatch > MakeBatch(bool flush_on_close=true)=0
Make a DatabaseBatch connected to this database.
void Open() override
Open the database if it is not already opened.
bool Backup(const std::string &strDest) const override
Back up the entire database to a file.
virtual void AddRef()=0
Indicate the a new database user has began using the database.
void reserve(size_type n)
virtual void Flush()=0
Make sure all changes are flushed to database file.
virtual bool ReadAtCursor(CDataStream &ssKey, CDataStream &ssValue, bool &complete)=0
virtual bool ReadKey(CDataStream &&key, CDataStream &value)=0
bool TxnCommit() override
std::atomic< int > m_refcount
Counts the number of active database users to be sure that the database is not closed while someone i...
void Flush() override
Make sure all changes are flushed to database file.
virtual bool Rewrite(const char *pszSkip=nullptr)=0
Rewrite the entire database on disk, with the exception of key pszSkip if non-zero.
std::unique_ptr< WalletDatabase > MakeDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
bool StartCursor() override
virtual std::string Format()=0
static const int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
virtual bool HasKey(CDataStream &&key)=0
WalletDatabase()
Create dummy DB handle.
std::string Filename() override
Return path to main database file for logs and error messages.
virtual bool PeriodicFlush()=0
Double ended buffer combining vector and stream-like interfaces.
virtual std::string Filename()=0
Return path to main database file for logs and error messages.
DatabaseBatch & operator=(const DatabaseBatch &)=delete
bool error(const char *fmt, const Args &... args)
bool Rewrite(const char *pszSkip=nullptr) override
Rewrite the entire database on disk, with the exception of key pszSkip if non-zero.
virtual bool StartCursor()=0
bool WriteKey(CDataStream &&key, CDataStream &&value, bool overwrite=true) override
bool IsSQLiteFile(const fs::path &path)
std::optional< DatabaseFormat > require_format
bool PeriodicFlush() override
void RemoveRef() override
Indicate that database user has stopped using the database and that it could be flushed or closed.